Setup E-mail test environment for Pinax(django)


There’re 2 ways to do it, the first  is sending the email out to an existing email address, the second is don’t actually send it, just print email out in your command line, which is very convenient for developers, so you don’t need to actually check your email.

The first way send to existing email address, let’s take 163.com mailbox for example:

Add following to your settings.py or local_settings.py

EMAIL_HOST = “smtp.163.com”



EMAIL_PORT = “25”



EMAIL_HOST_USER = “yourmailname@163.com”



EMAIL_HOST_PASSWORD = “yourpassword”



EMAIL_USE_TLS = False



DEFAULT_FROM_EMAIL = “yourmailname@163.com”



Now register an account on your pinax site, please input a invalid email address when you fill up the join up form. Then login as admin, go to url: http://localhost:8000/admin/mailer/me ...

you should be able see the confirm email message, maybe other email messages to be sent. Btw when you send an email in pinax, it will be listed here too.

If you want to actually send the email out, please enter your pinax environment, type:

python manage.py send_mail

If you use windows, probably you will see an error which says “NameError : global name ‘thread’ is not defined”. To solve this, you need go to yourpathto/pinax/Lib/site-packages/mailer/lockfile.py, add ‘import thread’ on line 59, now try type:

python manage.py send_mail, it should work for you now.

To send the emails have been deferred, you should type:

python manage.py retry_deferred

To make the notification actually out, you should type:

python manage.py emit_notices

If you windows you’ll probably will see error “NameError: global name ‘thread’ is not defined” again, now you need to go to yourpathto/pinax/Lib/site-packages/notification/lockfile.py, add ‘import thread’ on line59, it will work for you.

The second way is printing the email out in command line.

1. type this in your command line:

python -m smtpd -n -c DebuggingServer localhost:1025[[BR]]

Please keep the window open.

2. add the following in settings.py or local_settings.py

EMAIL_HOST = “localhost”



EMAIL_PORT = “1025”



3. send an email in pinax, you can do it by sign up new account, or any other way to do.

4. type this to actually send the email:

python manage.py send_mail

5. you’ll see the email message in your command line window of python -m smtpd -n -c DebuggingServer localhost:1025

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值