简体   繁体   中英

Cannot send mail using PEAR Mail for port 587 but yes for port 25

I cannot seem to get port 587 to send mail. I am capable of sending mail using port 25 . I'm using PEAR Mail to send this.

require_once "Mail.php";

/**************************************************
EDIT the following variables for your own use
***************************************************/
$from = "Noreply <noreply@host.com>";
$to = "Abc <abc@host.com>";

$subject = "Hi!"; //type in subject here

$host = "mail.host.com"; // also tried ssl://mail.host.com and tls://mail.host.com
$username = "noreply@host.com"; // Your user / full email address
$password = "password"; // Password to your email address

/**************************************************
***************************************************/

$body = "test message";
$headers = array (
'From' => $from,
'To' => $to,
'Date' => date('Y-m-d H:i:s'),
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password,
'port'=>587));

$mail = $smtp->send($to, $headers, $body);

Enable SMTP TLS / SSL in PEAR::MAIL

Edit the file - /pear/Net_SMTP/Net/SMTP.php

Find the line with the following content (approximately line 590):

function auth($uid, $pwd, $method = '', $tls = false, $authz = '')

Replace this with:

function auth($uid, $pwd, $method = '', $tls = true, $authz = '')

So your changing '$tls' from 'false' to 'true' Save the file And try with port 587

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM