Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 对于端口587,无法使用PEAR邮件发送邮件,但对于端口25,则为“是”_Php_Smtp - Fatal编程技术网

Php 对于端口587,无法使用PEAR邮件发送邮件,但对于端口25,则为“是”

Php 对于端口587,无法使用PEAR邮件发送邮件,但对于端口25,则为“是”,php,smtp,Php,Smtp,我似乎无法获得端口587来发送邮件。我可以使用端口25发送邮件。我用PEAR邮件发送这个 require_once "Mail.php"; /************************************************** EDIT the following variables for your own use ***************************************************/ $from = "Noreply <noreply

我似乎无法获得
端口587
来发送邮件。我可以使用
端口25
发送邮件。我用PEAR邮件发送这个

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);
require_once“Mail.php”;
/**************************************************
编辑以下变量供您自己使用
***************************************************/
$from=“Noreply”;
$to=“Abc”;
$subject=“你好!”//在这里输入主题
$host=“mail.host.com”;//也试过ssl://mail.host.com 及tls://mail.host.com
$username=”noreply@host.com"; // 您的用户/完整电子邮件地址
$password=“password”;//您的电子邮件地址的密码
/**************************************************
***************************************************/
$body=“测试消息”;
$headers=数组(
'From'=>$From,
'至'=>$至,
'Date'=>Date('Y-m-dh:i:s'),
“主题”=>$Subject);
$smtp=Mail::工厂('smtp',
数组('host'=>$host,
“auth”=>正确,
“用户名”=>$username,
“密码”=>$password,
'端口'=>587));
$mail=$smtp->send($to、$headers、$body);

在PEAR::MAIL中启用SMTP TLS/SSL

编辑文件-/pear/Net\u SMTP/Net/SMTP.php

查找包含以下内容的行(大约第590行):

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

将其替换为:

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

所以您将“$tls”从“false”更改为“true” 保存文件
并尝试使用端口587

是否有PEAR错误可以检查?@phansen数组(2){[0]=>int(530)[1]=>string(41)“5.7.0必须首先发出STARTTLS命令”}使用时是否存在相同的错误ssl://mail.host.com ?@phansen数组(2){[0]=>int(-1)[1]=>string(0)”“}用于
var\u转储($smtp->getSMTPObject()->getResponse())@phansen,因此ssl的返回代码为-1://