Drupal - PHP SMTP设置正确但电子邮件不会发送

I get the following error when my Drupal site tries to send out a welcome email when users are signed up: Failed to connect to mailserver at "secure.emailsrvr.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

I at first set the following in PHP.ini:

 SMTP = secure.emailsrvr.com
    SMTP_PORT = 465
    sendmail_from = support@managerspitstop.com
    username = support@managerspitstop.com
    password = ****

But I still got the error above so I added the following into the mail.inc file which is a file within the Drupal site:

 ini_set("SMTP","secure.emailsrvr.com");
    ini_set("smtp_port","465");
    ini_set("username", "support@managerspitstop.com");
    ini_set("password", "*****");
    ini_set("sendmail_from", "support@managerspitstop.com");

But still get the same error. So I contacted Rackspace who I have set up the email with and they have told me the settings I am using are correct. To test this I added the email to Outlook 2013 send out and email and received an email just fine.

I have looked around and couldn't find a solution. Any help will be greatly appreciated.

BLOODY DRUPAL! Managed to get it working. Turns out my email settings were correct the whole time.

I fixed it by downloading Drupals SMTP module which I placed in httpdocs/sites/all/modules/smtp and then I downloaded phpmailer version 2.2.1 (only required if you are running Drupal 6.x and do not use a version of PHPMailer any higher than 2.2.1 as it will not work) https://github.com/PHPMailer/PHPMailer/releases/tag/v2.2.1 I placed this at httpdocs/sites/all/modules/smtp/phpmailer.

Once that was sorted I went into the Administration section of my Drupal site and went to the modules section and typed in the email settings and BAM it worked :D.

Please note that this is just a hint for better investigation means, not an answer.

It would be beneficial to make a packet-level inspection of what exactly is going on at the time, when you try to send e-mail out.

For this, install tcpdump:

apt-get install tcpdump

and start a packet capture (run as root):

tcpdump -i any -s 0 -w /tmp/sniff-465.pcap port 465

Perform steps necessary to attempt the e-mail submission to the SMTP server, wait for the response and stop the packet capture by pressing CTRL+C. The resulting file (/tmp/sniff-465.pcap) can be analysed (using wireshark, i.e.) for exact behavior of the attempted SMTP transaction.