我是一名PHP程序员,在PHP中,您可以直接使用服务器发送电子邮件。例如,以下代码将电子邮件发送给客户端:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
但在Python中,您必须使用smtplib和Gmail或Hotmail服务器来发送电子邮件。 我想知道是否有办法直接从服务器使用Python发送电子邮件?
netstat -tuna
这样我们就可以检查SendMail是否按预期在本地监听。 - Robert Puttsock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it。
- Mohsen Koleynismtplib.SMTP('localhost')
上遇到了“拒绝连接”的错误。 - Shrike