简体   繁体   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

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 : 有解决方案:

  1. Install the SMTP server on your local. 在本地安装SMTP服务器。
  2. Use third party SMTP server. 使用第三方SMTP服务器。 (You are using GMAIL) (您正在使用GMAIL)

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.

相关问题 无法使用gmail ID从本地主机发送电子邮件 - Can't send email from localhost using gmail id 无法使用 Gmail 帐户在本地主机上通过 PHP 发送电子邮件 - Can't Send Email through PHP on localhost using Gmail account 我正在使用gmail服务器在我的xampp lite服务器上发送电子邮件,但我没有收到任何电子邮件 - I'm using gmail server to send email in my xampp lite server, but i'm not recieving any emails 我如何在Cakephp中发送电子邮件-从本地主机到gmail帐户 - how can i send email in cakephp - to gmail account from localhost 为什么我不能使用php发送电子邮件? - why can't i send email using php? 使用gmail从本地主机发送电子邮件 - Send email from localhost using gmail 为什么我不能使用 PHPMailer 发送电子邮件? - Why can I not send email using PHPMailer? 我可以在 xamp localhost 上使用 Swift Mailer 发送 email 消息吗 - Can I send email message using Swift Mailer on xamp localhost 我可以使用gmail帐户发送邮件,但是不能使用laravel 4从我的邮件主机发送邮件? - I can send from using gmail account but can't send mail using laravel 4 form my mail host? 为什么我不能在我的托管域中使用 swiftmailer 发送邮件,但是从我的本地主机服务器发送邮件时没有错误 - Why can I not send mail with swiftmailer in my hosted domain but there is no error when sending it from my localhost server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM