banner
ximalaya

ximalaya

这里是openkava 的blog,关注程序开发的一切技术。 ZZ 表示转载的文章,如涉及版权,请和我联系删除。 在这里你可以看到关于以下技术的文章: 移动开发技术,ANDROID ,IOS,WINDOWS PHONE平台开发,企业ERP开发,动态脚本PYTHON ,OPENGL ES 3D技术,游戏开发技术,HTML5 ,JAVASCRIPT ,MYSQL,AMAZON EC2 ,GOOGLE GAE ,GOOGLE CLOUD SQL 等 。 本站发展历程: 2010年,正式把所有的blog移到这里,租用godaddy的空间,记录生活和工作上的一些心得。 下面是关于我的个人介绍,写在这里权当凑字数啦。 职业:软件开发,开发经验6年,管理经验3年; 工作上使用的技术:C#, SQL SERVER 个人使用的技术:PYTHON,PHP, CSS, JAVA ,ANDROID ,object-c 等等 联系我请发邮件:<a href="http://blog.openkava.com/openkava@gmail.png"><img class="alignnone size-full wp-image-96" title="邮箱" src="http://blog.openkava.com/openkava@gmail.png" alt="" width="174" height="24" /></a>

Send email with Python

1 Python has a module called smtpd, which is used as an SMTP server to implement SMTP functionality for sending emails.

This module has 4 classes:

smtpd.SMTPServer: You need to implement the process_message function, which allows you to define how to handle the message content and send it to the corresponding mail servers. However, in my experiment on Windows, it didn't actually send emails and only acted as an empty SMTP server.

smtpd.PureProxy: Acts as a pure proxy for forwarding emails. It can send emails, and the actual data sent to external MX servers can be seen using Wireshark.

smtpd.MailmanProxy: Acts as a proxy for Mailman.

smtpd.DebuggingServer: Primarily used for debugging purposes.

2 SMTP is used as a client to send emails, similar to Foxmail and other email clients.

Usually, free SMTP servers require authentication to send emails and do not support relaying.

Therefore, you can only deliver emails to the MX servers of the recipient's email address.

By using nslookup and setting set type=mx, you can query the MX servers.

These MX servers do not require authentication. The following code can only send emails to email addresses with the qq.com domain. However, there is also a limit on the number of emails that can be sent. If you bypass IP verification through a proxy server, theoretically, you should be able to send unlimited emails.

Code:

import smtpd
import asyncore

print 'proxy start at 25 ...'

server = smtpd.PureProxy(('127.0.0.1', 25), ('mx1.qq.com', 25))
asyncore.loop()

 

 

 

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.