Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mailer error

Tags:

php

phpmailer

I tried to use php mailer but errors as follows.

SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. Message could not be sent.

Mailer Error: SMTP Error: Could not authenticate. 

and my code

 <?php
        require("class.phpmailer.php")
        $mail = new PHPMailer();        
        $mail->IsSMTP();                                    
        $mail->Host = "smtp.gmail.com";  
        $mail->Port = 465;        
        $mail->SMTPAuth = true;     

        $mail->SMTPDebug = 2;  
        $mail->Username = "[email protected]";  
        $mail->Password = "xxxxxxxx";   
        $mail->From = "[email protected]";
        $mail->FromName = "Mailer";
        $mail->AddAddress("[email protected]", "mine");               
        $mail->WordWrap = 50;                                 
        $mail->IsHTML(true);                                  

        $mail->Subject = "Here is the subject"  
        $mail->Body    = "This is the HTML message body <b>in bold!</b>";
        $mail->AltBody = "This is the body in plain text for non-HTML mail clients";


        if(!$mail->Send())  {
           echo "Message could not be sent. <p>";
           echo "Mailer Error: " . $mail->ErrorInfo;
           exit;
        }
        echo "Message has been sent";

        ?>
like image 480
ArK Avatar asked Feb 09 '10 08:02

ArK


People also ask

Does PHPMailer need SMTP?

For PHPMailer to be able to send emails from your PHP app, you will need to connect it to an SMTP server.

Does PHPMailer work on localhost?

The PHPMailer library provides the easiest way to send an email from localhost with an SMTP server using PHP. Not only the text email, but you can also send HTML email from localhost in PHP using PHPMailer.


1 Answers

I was getting this due to wrong port for SSL.

SSL = 465 TLS = 587

See: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

like image 189
Ashley Schroder Avatar answered Nov 15 '22 13:11

Ashley Schroder