小编Yhl*_*las的帖子

Python中的邮件客户端仅使用套接字(没有smtplib)

我正在尝试编写一个python程序,它将在不使用smtplib的情况下发送电子邮件.我试图查看其他帖子,但找不到解决方案.

`from socket import *


msg = "\r\n My email's content!"
endmsg = "\r\n.\r\n"

mailserver = ("smtp.aol.com", 25) 

clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect(mailserver)

recv = clientSocket.recv(1024)
recv = recv.decode()
print("Message after connection request:" + recv)
if recv[:3] != '220':
    print('220 reply not received from server.')
heloCommand = 'HELO Alice\r\n'
clientSocket.send(heloCommand.encode())
recv1 = clientSocket.recv(1024)
recv1 = recv1.decode()
print("Message after HeLO command:" + recv1)
if recv1[:3] != '250':
    print('250 reply not received from server.')

# #Info for username and password
# username …
Run Code Online (Sandbox Code Playgroud)

python sockets email

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

email ×1

python ×1

sockets ×1