【发布时间】:2019-08-26 17:55:27
【问题描述】:
我正在使用 PHPMailer 使用 SMTP 服务器发送电子邮件。我可以成功发送电子邮件。但是,我想用多个具有不同用户名和密码的 SMTP 服务器配置代码。如何实现这个功能。根据 PHPMailer 文档,我们可以提供备份 SMTP 服务器。但是如何配置不同的用户名和密码。
下面是代码sn-p,
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
请帮我解决这个问题。任何帮助将不胜感激。 谢谢。
【问题讨论】: