【问题标题】:How to configure SMTP settings based on web hosting's mail account如何根据虚拟主机的邮件帐户配置 SMTP 设置
【发布时间】:2014-11-04 08:07:37
【问题描述】:

您好,我如何配置我的 php 邮件程序以使其与这些设置一起使用?

我尝试修复用户名和密码,但仍然出现此错误 PHPMailer 错误:以下发件人地址失败:thesis@thesis.buybrand.com.ph :在未连接的情况下调用 Mail()

<?php
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'gowebph.gowebph.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
// or try these settings (worked on XAMPP and WAMP):
// $mail->Port = 465;
// $mail->SMTPSecure = 'ssl';


$mail->Username = "thesis@thesis.buybranded.com.ph";
$mail->Password = "XXXXXXXXXXXXXX";

$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.

$mail->From = "thesis@thesis.buybranded.com.ph";
$mail->FromName = "Your Name";

$mail->addAddress("vince_agno@live.com","User 1");
$mail->addAddress("2009010067@ust-ics.mygbiz.com","User 2");

$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";

if(!$mail->Send())
    echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
    echo "Message has been sent";
?>

【问题讨论】:

  • 尝试添加$mail->SMTPDebug = 4;启用详细调试输出。这可能会给你一个提示。

标签: php email smtp


【解决方案1】:

您的端口和协议不匹配。端口 465 用于 ssl,端口 587 用于 tls。 见https://support.google.com/mail/answer/13287?hl=en

【讨论】:

    【解决方案2】:

    你能用这个吗

    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    

    还有

    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465; 
    

    或者如果使用 TLS 尝试使用端口 587 进行 TLS

    来自 wiki ---Secure SMTP - 端口 587(也可以使用旧端口 465 - 这可能会解决 SSL 的问题)(端口 587 具有可选的 TLS 加密,现在可能使用 STARTTLS,或使用端口 465 进行 SSL 加密)

    【讨论】:

      猜你喜欢
      • 2014-09-01
      • 2017-05-27
      • 1970-01-01
      • 2014-12-08
      • 2020-07-17
      • 2018-07-04
      • 2011-05-04
      • 2014-10-29
      相关资源
      最近更新 更多