Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question