import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Email configuration
smtp_host = '192.168。21.20'
smtp_port = 25
password = 'mypassword'
subject = 'PHPMailer'
body = '3333333333'
# Prepare the email
msg = MIMEMultipart()
msg['From'] = from_email
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(body, 'html'))
try:
# Create a secure SSL context
print("AAAAAA")
server = smtplib.SMTP("10.54.21.20", 25, timeout=10) #这里报异常,可能是 25 端口有问题
print("BBBBBB")
# Uncomment the following line if SMTP authentication is needed
# server.login(username, password)
# Send the email
server.send_message(msg)
print("Message sent!")
except Exception as e:
print(f"Mailer Error: {e}")
finally:
server.quit()