我需要在webfaction的主机上使用email来给注册用户发邮件,它本机是不提供mail server的,需要单独配置邮件 email的配置,参考这个 http://docs.webfaction.com/user-guide/email.html 即新建mailbox,新建个发邮件账户,然后就是django中配置了。 django中配置参考这个: https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid;=181

EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'your_webfaction_mailbox_username'
EMAIL_HOST_PASSWORD = 'your_webfaction_mailbox_password'
DEFAULT_FROM_EMAIL = 'a real email address' # from address for server error emails
SERVER_EMAIL = 'a real email address' # used as the from address for django.core.mail.mail_admins() and django.core.mail.mail_managers()

注意:邮件服务器的地址是smtp.webfaction.com而不是mail.webfaction.com 配置好后,测试下:

In [1]: from django.core.mail import send_mail

In [2]: send_mail('Subject here', 'Here is the message.', '[email protected]',['[email protected]'])
Out[2]: 1

测试成功就可以接受到邮件了。