burnedfaceless
asked on
PHP Mail is going to Gmail but not Office 365 accounts
I'm sending a HTML email and it is arriving at gmail accounts but not at Office 365 Accounts. My code is below please help me troubleshoot.
if (isset($_POST['submit-forgot'])) {
$flag = true;
if (isset($_POST['email-forgot'])) {
$email = $_POST['email-forgot'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$alert = '<div class="alert alert-danger">You must enter a valid email address</div>';
$flag = false;
} else {
$sql = "SELECT * FROM users WHERE email = '$email'";
$result = $db->query($sql);
$array = $result->fetch_assoc();
if ($result->num_rows == 1) {
$hex = bin2hex(random_bytes(16));
$sql = "UPDATE users SET hex = '$hex' WHERE email = '$email'";
$result = $db->query($sql);
$to = $array['email'];
$subject = 'Password Reset';
include 'includes/mail.php';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: do-not-reply@effinghamministorage.com' . "\r\n";
$headers .= "To: $to\r\n";
mail($to, $subject, $message, $headers);
$alert = '<div class="alert alert-success">If the email address you entered is on file you will receive an email.</div>';
}
}
}
}
<?php
$message = '
<html>
<head>
<title>Reset Your Password</title>
</head>
<body>
<h1>Thanks for being a customer.</h1>
<h2>This link can only be used one time for security purposes.</h2>
<table cellspacing="0" style="border: 2px dashed #FB4314; width: 300px; height: 200px;">
<tr>
<th>Name:</th><td>CodexWorld</td>
</tr>
<tr style="background-color: #e0e0e0;">
<th>Email:</th><td>contact@codexworld.com</td>
</tr>
<tr>
<th>Reset Link:</th><td><a href="http://accounts.effinghamministorage.com/resetpassword.php?hex=' . $hex . '">Reset Password</a></td>
</tr>
</table>
</body>
</html>';
I suggest you try to email to a few other domains as well, it may have to do just with office 365, they may be ending up as spam.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys I'm going to install PHP Mailer and give that a try.
Tips #5 and #6 are the most critical ones from that article. Make sure you implement BOTH. They both have HUGE impacts in avoiding spam filters.
Thanks for the note about the new url, Dave. The article is about 8 years old so it definitely needs an update!
Thanks for the note about the new url, Dave. The article is about 8 years old so it definitely needs an update!