PHP邮件程序错误:无法发送邮件。邮件程序错误:SMTP connect()失败

PHP邮件程序错误:无法发送邮件。邮件程序错误:SMTP connect()失败,php,phpmailer,Php,Phpmailer,这是我的密码: require 'phpmailertesting/PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use

这是我的密码:

require 'phpmailertesting/PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'send.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'myemailhidden';                 // SMTP username
$mail->Password = 'mypasswordhidden';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also     accepted
$mail->Port = 465;                                    // TCP port to connect to

$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example@example.com');               // Name is optional

$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
要求“phpmailertesting/phpmailerautoad.php”;
$mail=新的PHPMailer;
//$mail->SMTPDebug=3;//启用详细调试输出
$mail->isSMTP();//将邮件程序设置为使用SMTP
$mail->Host='send.one.com';//指定主SMTP服务器和备份SMTP服务器
$mail->SMTPAuth=true;//启用SMTP身份验证
$mail->Username='myemailhidden';//SMTP用户名
$mail->Password='mypasswordhidden';//SMTP密码
$mail->SMTPSecure='ssl';//启用TLS加密,也接受'ssl'
$mail->Port=465;//要连接到的TCP端口
$mail->From='myemailhidden';
$mail->FromName='My Name';
$mail->addAddress('example@example.com');               // 名称是可选的
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz');//添加附件
//$mail->addAttachment('/tmp/image.jpg','new.jpg');//可选名称
$mail->isHTML(正确);//将电子邮件格式设置为HTML
$mail->Subject='主题在这里';
$mail->Body='这是以粗体显示的HTML邮件正文!';
$mail->AltBody='这是非HTML邮件客户端的纯文本正文';
如果(!$mail->send()){
echo“无法发送消息”;
回显“邮件错误:”。$mail->ErrorInfo;
}否则{
回音“消息已发送”;
}
我尝试将端口和安全连接的类型更改为“TSL”和“SSL”,而不更改任何内容。我已经看过答案了,但没有一个能解决它。有答案吗?谢谢


我启用了SMTP调试器,上面写着“连接:打开到”ssl://send.one.com:465,t=300,opt=array()2014-12-15 15:46:40 SMTP错误:无法连接到服务器:连接超时(110)2014-12-15 15:46:40 SMTP连接()失败“

您的托管公司one.com,故意阻止发送邮件端口以限制恶意PHP脚本。
send.one.com
地址用于外部邮件客户端,如您的手机、电子邮件客户端等,而不用于您网站的内部邮件脚本

根据他们关于从您的网站发送电子邮件的规定,您必须将主机更改为其内部SMTP地址,
mailout.one.com
——因为这是一个内部中继,您还必须使用端口25并禁用任何安全性,如TLS或SSL。您还必须禁用身份验证

以下是正确的配置:

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'mailout.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Authentication must be disabled
$mail->Username = 'myemailhidden';
$mail->Password = ''; // Leave this blank
$mail->Port = 25;                                    // TCP port to connect to

其他的解决方案对我不起作用;这一次:

$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false;                            // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = '';                            // leave this blank!
$mail->Port = 25;   

如果这对你也有帮助,请告诉我

SO新手,所以不能投票给你@sjagr

有这个问题,当我使用one.com时,@sjagr:)的解决方案没有什么大不了的

您可以在文件中尝试此完整输出,并确保链接所需的文档

<?php

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host       = "mailout.one.com";
$mail->SMTPAuth   = false;
$mail->Port = 25;
$mail->From = 'your@domain.se';
$mail->FromName = 'Mailer';
$mail->addAddress('sendtothis@domain.se');
$mail->addReplyTo('ireply@domain.se', 'Information');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body    = 'hejehej';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {

    echo 'Message could not be sent.';
    //echo 'Mailer Error: ' . $mail->ErrorInfo;

} else {

    echo 'Message has been sent, ja e fan inte tom';

} ?>


telnet send.one.com 465
适合我。将
$mail->SMTPSecure
行一起取出,看看是否有效?尝试一下。仍然失败,出现相同的错误:(谁是您的网络主机?可能有一些传出的IPTables规则阻止您从端口465.one.com进行通信。我将尝试使用我的google帐户。看看是否有效:)这是他们说您需要找到更好的ISP的方式。仍然没有运气:(相同的错误消息。真奇怪!@SteMain禁用身份验证,并删除用户名/密码字段。确保您的“发件人”地址属于您的托管域。是的,它起作用了。我使用了端口25,没有身份验证。这意味着什么?与one.com有关吗?@SteMain是的。one.com这样做可能是出于安全原因-但这个问题是您的托管公司特有的,在许多其他主机上不太可能发现。@SteMain不幸的是,它仍然不起作用k为我-您能展示一下对您有用的完整设置吗?谢谢!