[英]“SMTP connect() failed”. When configuring it to send emails from remote Host
I am new at PHP. 我是PHP新手。 I am using PHPMailer to send emails but unable to do so.
我使用PHPMailer发送电子邮件但无法这样做。 I tried configuring it for gmail and it worked But not working when tried to send msg from remote host and for the given domain.
我尝试为gmail配置它并且它工作但是当试图从远程主机和给定域发送消息时不工作。 Here is the code.
这是代码。
<?php
require("PHPMailerAutoload.php"); // path to the PHPMailerAutoload.php file.
$mail = new PHPMailer();
//$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "175.000.000.000"; //Sample Host
$mail->SMTPDebug = 1;
$mail->Port = "25"; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$mail->SMTPAuth = true;
//$mail->SMTPSecure = 'ssl';
$mail->Username = "maaz@mcbah.com";
$mail->Password = "password";
$mail->From = "maaz@mcbah.com";
$mail->FromName = "Maaz Khan";
$mail->AddAddress("mcbah.all@mcbah.com", "all");
$mail->AddReplyTo("fundprices@mcbah.com", "Fund");
$mail->Subject = "Hi!";
$mail->Body = "Hi! How are you?";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
echo 'Not sent: <pre>'.print_r(error_get_last(), true).'</pre>';
exit;
} else {
echo 'Message has been sent.';
}
This code may help you 此代码可能对您有所帮助
$mail->Host = "smtpout.secureserver.net";
$ mail-> Host =“smtpout.secureserver.net”;
Your host name should be like mydomain.com
$mail->Port = 465;
$ mail-> Port = 465;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.