更新时间:2023-10-14 08:32:16
发送电子邮件时通过需要SMTP认证的服务器,您真的需要指定它,并设置主机,用户名和密码(也可能是端口,如果不是默认端口)。
When you are sending an e-mail through a server that requires SMTP Auth, you really need to specify it, and set the host, username and password (and maybe the port if it is not the default one - 25).
例如,我通常使用PHPMailer与此类似的设置:
For example, I usually use PHPMailer with similar settings to this ones:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // SMTP account username example
$mail->Password = "password"; // SMTP account password example
您可以在这里找到有关PHPMailer的更多信息: https://github.com/PHPMailer/PHPMailer
You can find more about PHPMailer here: https://github.com/PHPMailer/PHPMailer