[英]Why I can't send email using my domain local but if I'm using gmail it will successfully send in localhost
Why I can't send email using my domain in localhost? 为什么我无法在localhost中使用我的域发送电子邮件? But when I used gmail smtp it's successfully sent email (in localhost)
但当我使用gmail smtp时,它已成功发送电子邮件(在localhost中)
This is the error using debug=4 : 这是使用debug = 4的错误:
2016-08-31 07:08:05 Connection: opening to ssl://mail.mydomain.com:443, timeout=300, options=array ( ) 2016-08-31 07:08:05 Connection: opened
this is my code 这是我的代码
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.mydomain.mncgroup.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'emailsender@mydomain.com'; // SMTP username
$mail->Password = 'pass'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 443;
$mail->SMTPDebug=4;
$mail->setFrom('emailsender@mydomain.com', 'a');
$mail->addReplyTo('emailsender@mydomain.com', 'a');
$mail->addAddress('myemail.mydomain.com'); // Add a recipient
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Reminder ';
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
There is a lesser probability of sending mails from localhost as it requires SMTP server, and that is not installed by default. 从localhost发送邮件的可能性较小,因为它需要SMTP服务器,默认情况下不会安装。 So you cannot send mails from local directly.
因此,您无法直接从本地发送邮件。 There are solutions :
有解决方案:
In case you go by second solution, Please go through the below link 如果您使用第二个解决方案,请通过以下链接
http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.