我似乎无法让port 587
发送邮件。我可以使用port 25
发送邮件。我使用PEAR Mail发送此邮件。
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);
答案 0 :(得分:0)
在PEAR :: MAIL中启用SMTP TLS / SSL
编辑文件 - /pear/Net_SMTP/Net/SMTP.php
找到包含以下内容的行(大约第590行):
function auth($ uid,$ pwd,$ method ='',$ tls = false,$ authz ='')
将其替换为:
function auth($ uid,$ pwd,$ method ='',$ tls = true,$ authz ='')
所以你将'$ tls'从'false'改为'true' 保存文件 尝试使用端口587