PHP SMTP mail function not working with phpmailer [closed]

对着背影说爱祢 提交于 2021-02-05 08:57:51

问题


PHP SMTP mail function not working with phpmailer and throwing following error

Error: SMTP Error: Language string failed to load: tls.

My Code is :

require_once('class.phpmailer.php');

$mail  = new PHPMailer();   
$mail->IsSMTP();    
$mail->SMTPAuth   = True;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the server
$mail->Host       = "localhost";      
$mail->Port       = 25;                 
$mail->Username   = "xxxxxx@xxxxx.org.in";  // my username
$mail->Password   = "xxxx";            // my password

$mail->From       = "xxxxxxx@xxxxx.org.in";
$mail->FromName   = "you name";
$mail->Subject    = "some subject";
$mail->MsgHTML("the message");

$mail->AddAddress("yyyyyy@gmail.com","logan");
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {//to see if we return a message or a value bolean
    echo "Mailer Error: " . $mail->ErrorInfo;
} else  echo "Message sent!";

I have got the host and port details my web service provider but not working.

When i debug, following is the error:

SMTP -> FROM SERVER:220 We do not authorize the use of this system to transport unsolicited, and/or bulk e-mail.
SMTP -> FROM SERVER: 250-mail02.clientns.net [127.0.0.1], this server offers 4 extensions 250-AUTH LOGIN 250-SIZE 52428800 250-HELP 250 AUTH=LOGIN
SMTP -> FROM SERVER:503 Bad sequence of commands
SMTP -> ERROR: STARTTLS not accepted from server: 503 Bad sequence of commands
SMTP -> FROM SERVER:250 Requested mail action okay, completed
Language string failed to load: tls Mailer Error: Language string failed to load: tls

Could any one please let me know why is it not connecting ?


回答1:


It worked for me when i remove following..

//$mail->SMTPSecure = "tls";



回答2:


You tell PHPMailler to use a secured mail service hosted on your server. If you don't know if it's the case, comment the lines as this and test it (it will use php native "mail()" function as described here):

require_once('class.phpmailer.php');

$mail  = new PHPMailer();   
//$mail->IsSMTP();    
//$mail->SMTPAuth   = false;                  // enable SMTP authentication
//$mail->SMTPSecure = "ssl";                 // sets the prefix to the server
//$mail->Host       = "localhost";      
//$mail->Port       = 25;                 
//$mail->Username   = "xxxxxx@xxxxx.org.in";  // my username
//$mail->Password   = "xxxx";            // my password

$mail->From       = "xxxxxxx@xxxxx.org.in";
$mail->FromName   = "you name";
$mail->Subject    = "some subject";
$mail->MsgHTML("the message");

$mail->AddAddress("yyyyyy@gmail.com","logan");
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {//to see if we return a message or a value bolean
    echo "Mailer Error: " . $mail->ErrorInfo;
} else  echo "Message sent!";


来源:https://stackoverflow.com/questions/14305440/php-smtp-mail-function-not-working-with-phpmailer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!