E
E
Eugene Khablak2018-02-08 13:48:55
PHP
Eugene Khablak, 2018-02-08 13:48:55

Why doesn't phpMailer send smtp mail locally?

private function sendInternal($to, $subject, $html, $text, $from = null)
    {
        $mail = new \PHPMailer;
        if ($from == null) {
            $from = '[email protected]';
        }
        $mail->SMTPDebug = 4;
        $mailsConfig = conf('mail');
        if ($mailsConfig['isSMTP']) {
            $mail->isSMTP();  // tell the class to use SMTP
            $mail->SMTPAuth = $mailsConfig['SMTPAuth']; // enable SMTP authentication

            // $mail->SMTPSecure = 'ssl';

            $mail->Port = 465; // set the SMTP port
            $mail->Host = "smtp.gmail.com"; // SMTP server
            $mail->Username = $mailsConfig['Username']; // SMTP account username
            $mail->Password = $mailsConfig['Password'];     // SMTP account password
        }
        $mail->setFrom($from);
        //Set an alternative reply-to address
        $mail->addReplyTo($from);
        //Set who the message is to be sent to
        $mail->addAddress($to);
        //Set the subject line
        $mail->Subject = $subject;
        //Read an HTML message body from an external file, convert referenced images to embedded,
        //convert HTML into a basic plain-text alternative body
        $mail->msgHTML($html);

        //Replace the plain text body with one created manually
        $mail->AltBody = $text;

        if (!$mail->send()) {
            throw new \Exception($mail->ErrorInfo);
            return false;
        } else {
            return true;
        }

The error looks like. way
5a7c295a88eac454208668.png
If you comment out the smpt block, the error looks like the following.
5a7c29d954885916027623.png
I downloaded sendmail.zip, which I unzipped to "C:/wamp64/" .
sendmail.ini looks like
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
default_domain=localhost
error_logfile=error.log
debug_logfile=debug.log
auth_username={MYGMAIL}
auth_password={MYGMAILPASS}
pop3_server=
pop3_username=
pop3_password=
force_sender=
force_recipient=
hostname=localhost
php.ini which is located in the folder with apache configured sendmail_path
username and password I specify correctly 100%
And it's definitely a mistake. What's wrong, how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question