I use PHPMailer to send emails to recipients from [email protected] to [email protected] but when I send it goes directly to spam/jusnk folder.
Here is the code I used to send
$mail = new PHPMailer(true);
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->Username = $email;
$mail->Password = $password;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Recipient & sender info
$mail->setFrom($email, 'no-reply');
$mail->addAddress($receiver);
$mail->addReplyTo($email);
// Message content
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'Here is body';
// Send mail
$mail->send();
It supposed to go to main folder not to spam/junk folder.
New contributor
Abdelghani Elyagoubi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.