我是 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);
?>
Run Code Online (Sandbox Code Playgroud)
但在 python 中,您必须使用 smtplib 和 gmail 或 hotmail 服务器来发送电子邮件。我想知道是否可以直接从服务器发送带有 python 的电子邮件?