nur alam
nur alam

Reputation: 127

PHPMailer didn't send email message

I try to send email with PHPMailer but getting error.I use port 465 and 587 both are getting error also in SSL and TLS. Error like bellow

2016-06-09 18:55:06 Could not instantiate mail function. Message could not be sent.Mailer Error: Could not instantiate mail function.

How can i solve this and can send email message.

        $mail = new PHPMailer;

        $mail->isSMTP();
        $mail->Host = 'smtp.gmail.com';
        $mail->SMTPAuth = true;
        $mail->Username = '[email protected]';
        $mail->Password = '********';
        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;   

        $mail->From = '[email protected]';
        $mail->FromName = 'nuralam';
        $mail->addAddress('[email protected]', 'nuralam');

        $mail->addReplyTo('[email protected]', 'nuralam');

        $mail->WordWrap = 50;
        $mail->isHTML(true);
        $mail->SMTPDebug = 1; 
        $mail->Subject = 'Using PHPMailer';
        $mail->Body    = 'Hi Iam using PHPMailer library to sent SMTP mail from localhost';

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

Upvotes: 1

Views: 1579

Answers (1)

Synchro
Synchro

Reputation: 37730

First up, you're using an old version of PHPMailer and you need to read the docs. Get the latest.

Because you're using SMTP directly, you don't need a local mail server.

If you increase SMTP debug output you'll be able to see what responses you're getting from the server, which is very likely to be an authentication problem, as described in the troubleshooting guide.

$mail->SMTPDebug = 2;

Upvotes: 1

Related Questions