簡體   English   中英

為什么我不能使用我的本地域發送電子郵件,但如果我使用gmail,它將成功發送到localhost

[英]Why I can't send email using my domain local but if I'm using gmail it will successfully send in localhost

為什么我無法在localhost中使用我的域發送電子郵件? 但當我使用gmail smtp時,它已成功發送電子郵件(在localhost中)

這是使用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

這是我的代碼

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';
}

從localhost發送郵件的可能性較小,因為它需要SMTP服務器,默認情況下不會安裝。 因此,您無法直接從本地發送郵件。 有解決方案:

  1. 在本地安裝SMTP服務器。
  2. 使用第三方SMTP服務器。 (您正在使用GMAIL)

如果您使用第二個解決方案,請通過以下鏈接

http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM