PHP()Mail& SMTP问题

时间:2015-01-18 02:32:07

标签: php wordpress .htaccess email ftp

我知道这个问题已被问了一百万次,但我一直试图找到解决我的问题近18个小时 - 直接!

压力很大......

这是一个漫长的问题,但我试图尽可能多地提供有关可能导致错误的不同信息。

我将我当前的网站irishgroupage.co.uk设置在我自己的WHMCS主机帐户上,一切正常。我切换到以前托管旧的html网站的公司主要托管服务提供商,现在我无法让邮件工作。

由于某种原因,wordpress默认的PHP邮件程序和SMTP设置完全被打破了。

它开始时它无法连接到任何SMTP服务器,即使我知道我自己的主机允许这个事实 - 因为它在昨晚和前一天工作没有问题。它还与我在自己的服务器上设置的一些客户合作 - 所以我的电子邮件服务没有问题。

默认的PHP邮件程序只需输入我们的Gmail电子邮件即可。

所以在几个试图让它工作之后,我现在得到了这个错误;

SMTP -> ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it.
 (10061)

由于尝试次数太多,我不确定我的域名是否已被列入黑名单。可能被标记为垃圾邮件?但我现在在我在这个域上使用的每个电子邮件帐户和SMTP帐户都会收到此错误。

在我自己的托管中,该网站位于Public_html目录中,但是我无法将其放在当前的Public_html目录中,因为我在加载网站时会收到403禁止错误页面。这个托管公司必须有一些安全措施

在我自己的托管中,我们有邮件目录,在这一个我有邮件目录以及一个带有php邮件文件夹的php文件夹。我想知道这两个目录是否与wp-mail文件冲突,因为整个网站都在ftp帐户的根目录中。

所以要明确我的网站在FTP中的设置方式

当前托管

  • PHP - 包含PHP-Mailer
  • 邮件 - 包含我的电子邮件
  • Public_html - 不包含任何内容
  • 我的所有网站文件,包括wp-mailer文件。

旧托管

  • 邮件 - 包含我的电子邮件
  • Public_html - 我的所有网站文件

我会切换回自己的主机,但我似乎无法设置交换服务器,所以现在不是一个选项。

您可以在下面看到完整的错误报告

Test Message Sent
The result was:
bool(false)
The full debugging output is shown below:
object(PHPMailer)#4484 (69) {
  ["Version"]=>
  string(5) "5.2.7"
  ["Priority"]=>
  int(3)
  ["CharSet"]=>
  string(5) "UTF-8"
  ["ContentType"]=>
  string(10) "text/plain"
  ["Encoding"]=>
  string(4) "8bit"
  ["ErrorInfo"]=>
  string(22) "SMTP connect() failed."
  ["From"]=>
  string(23) "irishgroupage@gmail.com"
  ["FromName"]=>
  string(23) "Irish Groupage Services"
  ["Sender"]=>
  string(0) ""
  ["ReturnPath"]=>
  string(0) ""
  ["Subject"]=>
  string(51) "WP Mail SMTP: Test mail to andy@irishgroupage.co.uk"
  ["Body"]=>
  string(68) "This is a test email generated by the WP Mail SMTP WordPress plugin."
  ["AltBody"]=>
  string(0) ""
  ["Ical"]=>
  string(0) ""
  ["MIMEBody":protected]=>
  string(69) "This is a test email generated by the WP Mail SMTP WordPress plugin.
"
  ["MIMEHeader":protected]=>
  string(463) "Date: Sun, 18 Jan 2015 02:08:42 +0000
Return-Path: 
To: andy@irishgroupage.co.uk
From: Irish Groupage Services 
Subject: WP Mail SMTP: Test mail to andy@irishgroupage.co.uk
Message-ID: <69cde0c871a661784c186899491037c4@irishgroupage.co.uk>
X-Priority: 3
X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

"
  ["mailHeader":protected]=>
  string(0) ""
  ["WordWrap"]=>
  int(0)
  ["Mailer"]=>
  string(4) "smtp"
  ["Sendmail"]=>
  string(18) "/usr/sbin/sendmail"
  ["UseSendmailOptions"]=>
  bool(true)
  ["PluginDir"]=>
  string(0) ""
  ["ConfirmReadingTo"]=>
  string(0) ""
  ["Hostname"]=>
  string(0) ""
  ["MessageID"]=>
  string(0) ""
  ["MessageDate"]=>
  string(0) ""
  ["Host"]=>
  string(14) "smtp.gmail.com"
  ["Port"]=>
  string(3) "587"
  ["Helo"]=>
  string(0) ""
  ["SMTPSecure"]=>
  string(3) "tls"
  ["SMTPAuth"]=>
  bool(true)
  ["Username"]=>
  string(23) "irishgroupage@gmail.com"
  ["Password"]=>
  string(12) ""
  ["AuthType"]=>
  string(0) ""
  ["Realm"]=>
  string(0) ""
  ["Workstation"]=>
  string(0) ""
  ["Timeout"]=>
  int(10)
  ["SMTPDebug"]=>
  bool(true)
  ["Debugoutput"]=>
  string(4) "echo"
  ["SMTPKeepAlive"]=>
  bool(false)
  ["SingleTo"]=>
  bool(false)
  ["SingleToArray"]=>
  array(0) {
  }
  ["do_verp"]=>
  bool(false)
  ["AllowEmpty"]=>
  bool(false)
  ["LE"]=>
  string(1) "
"
  ["DKIM_selector"]=>
  string(0) ""
  ["DKIM_identity"]=>
  string(0) ""
  ["DKIM_passphrase"]=>
  string(0) ""
  ["DKIM_domain"]=>
  string(0) ""
  ["DKIM_private"]=>
  string(0) ""
  ["action_function"]=>
  string(0) ""
  ["XMailer"]=>
  string(0) ""
  ["smtp":protected]=>
  object(SMTP)#4485 (12) {
    ["Version"]=>
    string(5) "5.2.7"
    ["SMTP_PORT"]=>
    int(25)
    ["CRLF"]=>
    string(2) "
"
    ["do_debug"]=>
    bool(true)
    ["Debugoutput"]=>
    string(4) "echo"
    ["do_verp"]=>
    bool(false)
    ["Timeout"]=>
    int(10)
    ["Timelimit"]=>
    int(30)
    ["smtp_conn":protected]=>
    bool(false)
    ["error":protected]=>
    NULL
    ["helo_rply":protected]=>
    NULL
    ["last_reply":protected]=>
    string(0) ""
  }
  ["to":protected]=>
  array(1) {
    [0]=>
    array(2) {
      [0]=>
      string(24) "andy@irishgroupage.co.uk"
      [1]=>
      string(0) ""
    }
  }
  ["cc":protected]=>
  array(0) {
  }
  ["bcc":protected]=>
  array(0) {
  }
  ["ReplyTo":protected]=>
  array(0) {
  }
  ["all_recipients":protected]=>
  array(1) {
    ["andy@irishgroupage.co.uk"]=>
    bool(true)
  }
  ["attachment":protected]=>
  array(0) {
  }
  ["CustomHeader":protected]=>
  array(0) {
  }
  ["lastMessageID":protected]=>
  string(54) "<69cde0c871a661784c186899491037c4@irishgroupage.co.uk>"
  ["message_type":protected]=>
  string(5) "plain"
  ["boundary":protected]=>
  array(3) {
    [1]=>
    string(35) "b1_69cde0c871a661784c186899491037c4"
    [2]=>
    string(35) "b2_69cde0c871a661784c186899491037c4"
    [3]=>
    string(35) "b3_69cde0c871a661784c186899491037c4"
  }
  ["language":protected]=>
  array(18) {
    ["authenticate"]=>
    string(35) "SMTP Error: Could not authenticate."
    ["connect_host"]=>
    string(43) "SMTP Error: Could not connect to SMTP host."
    ["data_not_accepted"]=>
    string(30) "SMTP Error: data not accepted."
    ["empty_message"]=>
    string(18) "Message body empty"
    ["encoding"]=>
    string(18) "Unknown encoding: "
    ["execute"]=>
    string(19) "Could not execute: "
    ["file_access"]=>
    string(23) "Could not access file: "
    ["file_open"]=>
    string(33) "File Error: Could not open file: "
    ["from_failed"]=>
    string(35) "The following From address failed: "
    ["instantiate"]=>
    string(36) "Could not instantiate mail function."
    ["invalid_address"]=>
    string(15) "Invalid address"
    ["mailer_not_supported"]=>
    string(25) " mailer is not supported."
    ["provide_address"]=>
    string(54) "You must provide at least one recipient email address."
    ["recipients_failed"]=>
    string(45) "SMTP Error: The following recipients failed: "
    ["signing"]=>
    string(15) "Signing Error: "
    ["smtp_connect_failed"]=>
    string(22) "SMTP connect() failed."
    ["smtp_error"]=>
    string(19) "SMTP server error: "
    ["variable_set"]=>
    string(30) "Cannot set or reset variable: "
  }
  ["error_count":protected]=>
  int(2)
  ["sign_cert_file":protected]=>
  string(0) ""
  ["sign_key_file":protected]=>
  string(0) ""
  ["sign_key_pass":protected]=>
  string(0) ""
  ["exceptions":protected]=>
  bool(true)
}
The SMTP debugging output is shown below:
SMTP -> ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it.
 (10061)

如果有人可以帮助我,请做。我现在正以惊人的速度退缩!

您知道,我已经删除了邮件和PHP目录,并再次尝试查看它们是否发生冲突,但无济于事;我仍然得到相同的错误报告:(

谢谢你们

3 个答案:

答案 0 :(得分:0)

我认为你需要在发送之前进行POP3身份验证(我自己试试。)

请参阅此example

注意第11行。在链接中他们做的有点不同,但这就是我做的方式:

$pop = new POP3();
$pop->Authorise($host, $port, $timeout, $username, $password, 1);

如果您的外发SMTP服务器需要身份验证,则需要在发送之前进行POP3身份验证。

然后运行你已经在做的其他事情。

答案 1 :(得分:0)

  

[&#34;用户名&#34;] =&GT; string(23)&#34; irishgroupage@gmail.com"

您发送的邮件来自irishgroupage@gmail.com

  

[&#34;&进行AuthType#34;] =&GT; string(0)&#34;&#34;

没有任何身份验证 - 即没有凭证来证明你是谁。当然,Gmail不会与您联系。

但这可能不是你唯一的问题。您还没有提到服务器上的端口是否打开。您的主机可能已经防火墙,这可能是导致连接问题的原因。

安装此插件:https://wordpress.org/plugins/postman-smtp/并使用设置向导。它将测试您的端口以找出哪些是打开的,然后配置自己以便正确地向Gmail发送邮件。

答案 2 :(得分:0)

您可以在登录后使用发送电子邮件的电子邮件ID转到此链接...

在这里,尝试登录不太安全的应用程序: https://www.google.com/settings/u/1/security/lesssecureapps

在这里,只需点击继续... https://accounts.google.com/b/0/DisplayUnlockCaptcha

并检查此处是否有任何记录到您的帐户: https://security.google.com/settings/security/activity?hl=en&pli=1

然后,运行你的代码..希望它可以帮助你......