phpemaillaravelphpmailer

Can't send emails using Laravel 5.0.33


I was trying to send emails using the code below:

'driver' => 'smtp',
'host' => 'a2plcpnl0296.prod.iad2.secureserver.net;a2plcpnl0296.prod.iad2.secureserver.net',
'port' => 587,
'from' => ['address' => 'contact@theventuregame.com', 'name' => 'The Venture Game TM'],
'encryption' => 'tls',
'username' => 'xxx',
'password' => 'yyy',
'pretend' => false,

When I try to send email using these conf the error shows as below: Connection could not be established with host a2plcpnl0296.prod.iad2.secureserver.net;a2plcpnl0296.prod.iad2.secureserver.net [php_network_getaddresses: getaddrinfo failed: No such host is known. #0].

I think I know what the issue is, to add SMTP Authentication to true, but I just don't know where can I put that parameter.

On the other hand I have this code which works perfectly fine, but I would want the Laravel one config as it is more clean:

        $this->mail = new PHPMailer;
        $this->mail->isSMTP();                                      // Set mailer to use SMTP
        $this->mail->Host = 'a2plcpnl0286.prod.iad2.secureserver.net;a2plcpnl0286.prod.iad2.secureserver.net';  // Specify main and backup SMTP servers
        $this->mail->SMTPAuth = true;                               // Enable SMTP authentication
        $this->mail->Username = 'xxx';                 // SMTP username
        $this->mail->Password = 'yyy';                           // SMTP password
        $this->mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
        $this->mail->Port = 587;                                    // TCP port to connect to

        $this->mail->From = 'contact@theventuregame.com';
        $this->mail->FromName = 'The Venture Game TM';

As you can see on the above code I have this:

$this->mail->SMTPAuth = true; 

Which I think if I would have it declared somewhere in Laravel would make it work.

Any suggestions?


Solution

  • This isn't an auth problem - it's not getting that far.

    The Host property is documented here and the Host string is split on ;. You have listed the same server twice in your Host property. Try just setting it to a2plcpnl0286.prod.iad2.secureserver.net. Beyond that, set SMTPDebug = 4 and you'll get verbose output telling you about the connection.

    You should check that that email server is actually accessible - how to do that is covered in the troubleshooting guide.

    Make sure you're using the latest PHPMailer too.

    I also note you're on GoDaddy, who have notoriously bad email support.