twistd工具搭建mail服务器

来源:互联网 发布:阿里云备案转入腾讯云 编辑:程序博客网 时间:2024/05/21 08:47

客户端源代码

from twisted.internet import reactorfrom twisted.mail.smtp import sendmailfrom twisted.python import logfrom email.mime.text import MIMETextimport syslog.startLogging(sys.stdout)#host = 'aspmx.l.google.com'host = 'localhost'#sender = 'secretadmirer@example.com'sender = 'secretadmirer@unknown.com'#receipients = ['twistedechobot@gmail.com']#receipients = ['recipients@localhost']receipients = ['ds@example.com']msg = MIMEText('''Violets are blueTwisted is helpingForge emails to you!''')msg['subject'] = 'Roses are red'msg['from'] = '"Secret Admirer" <%s>' % (sender,)msg['to'] = ','.join(receipients)#deferred = sendmail(host,sender,receipients, msg.as_string(),port=25)deferred = sendmail(host, sender,receipients, msg.as_string(),port=8025)deferred.addBoth(lambda x:reactor.stop())reactor.run()

twistd.py工具命令:


0 0
原创粉丝点击