PhpMailer not arriving in Hotmail?

After setting up the SPF record, I'm still here to check why I canโ€™t get this email in my hotmail account. I can send it to gmail without any problems. Verify the code is correct and the SPF record is correct:

<?php require_once 'PHPmailer/class.phpmailer.php'; $mail = new PHPMailer(); $body = "Thankyou for your Purchase. <br/><br/> Here is your Policy! You are now Protected during your Travels."; $mail->AddAddress('$payer_email'); $mail->From = "noreply@example.com"; $mail->FromName = "Name"; $mail->Subject = "Thankyou for Your Purchase"; $mail->MsgHTML($body); $mail->AddAttachment("tosend/xxx.pdf"); if(!$mail->Send()) { echo "There was an error sending the message"; $sql = "UPDATE purchases SET policy_sent = 'Not Sent' WHERE id = '$lastid' "; $stmt = $mysqli->query($sql); $mysqli->close(); exit; } echo "Message was sent successfully"; $sql = "UPDATE purchases SET policy_sent = 'Sent', email_to = '$payer_email' WHERE id = '$lastid'"; $stmt = $mysqli->query($sql); $mysqli->close(); ?> 

Here is the SPF:

 v=spf1 a mx include:secureserver.net ~all 

Are they configured correctly?

+8
php phpmailer
source share
6 answers

There was the same problem. I checked the whole script 30 times. Each parameter is each. and, Checked and double-checked dns writes dkim and spf 100 times.

Nothing succeeded.

I emailed hotmail / outlook / live about the problem. I did not expect any help, but after a few hours the problem was resolved.

This was not in the script. Hotmail simply blocks any email that is sent through most web pages. Even if your spam reputation is wonderful. They whitelisted the ip server and the problem was resolved.

They can change it if they detect bad behavior. There is a restriction on sending e-mail. If your server has a bad reputation, it is unlikely to add the server to its whitelist. This can be a problem for shared hosting packages. Someone else on the same server where you host your site can maintain a server reputation.

0
source share

Use SMTP Auth, then Hotmail will no longer complain. Anonymous emails are considered spam on almost all receiving servers.

 $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.yourdomain.com"; // sets the SMTP server $mail->Port = 26; // set the SMTP port $mail->Username = "yourname@yourdomain"; // SMTP account username $mail->Password = "yourpassword"; // SMTP account password 

But ofc. depending on whether you have control over your SMTP or not, you need to make sure that basic elements such as reverse-dns-lookup are configured correctly


Due to the discussion in the comments, I want to add a little more information about my thinking about why SMTP Auth will fix this:

IF you use PHPMailer without defining an SMTP server, PHPMailer will operate in mail mode, which simply calls the mail() php function.

The mail function itself will use the smtp parameters configured in the PHP-INI file, or the default values โ€‹โ€‹that are listed here: http://php.net/manual/en/mail.configuration.php

default:

 SMTP = "localhost" smtp_port = "25" 

Since the OP has configured a local mail server (or why did it set MX records?), Php will now connect to this SMTP server without authentication. The server will accept the message and send it to the next server.

(The same applies if unix 'sendmail is used)

Each server in the chain and especially on the receiving server can now see that private SMTP is being used and authentication is not provided. This is already a Spam-Score of more than 9000, because with this setting (theoretically) everyone can use this server to send letters! Limitations, as only from localhost, are cc. unknown to other servers, so SMTP is considered Email Relay http://en.wikipedia.org/wiki/Open_mail_relay

Switching PHPMailer to SMTP-Auth (EVEN if using a local SMTP server) will add this information to the record created by the server when forwarding mail. The entry will look like this:

 Received: from SERVER1 ([xxx.xxx.xxx.xx]) by mydomain.de with ESMTPA 

Finishing A after ESMTPA now tells the receiving server that Server1 used a valid user account on mydomain.de to start sending, which means that the SMTP server knows the origin of the mail and can provide information about the sender.

However, the local SMTP server is not known, so in this case it may appear as greylisted and checked on different RBLs, which should not be a problem in this case.

If the (local) SMTP server now passes ALL checks (reverse DNS lookup, Greylisting, RBL, and what not) - mail has a good chance of successful delivery, even if the remote smtp is not used, since the server can be authenticated successfully, as well sender using this server. (Otherwise, no company could set up their own servers)

Thus, using SMTP-Auth (or any other authentication method) will also have an effect, even if you are not using a remote SMTP server.

Authenticated emails are not a guarantee that they are not considered spam, but unauthenticated emails are definitely ranked in the Spam-Score of common systems.

+5
source share

Have you tested on a real server? If so, what error did you get? Have you enabled the phpmailer debugger to find out what errors it has? If you are not using SMTP, you can test this with

$mail->do_debug = true;

If you use SMTP, use

$mail->SMTPDebug = true;

What result did you get from your debugger? You will find out where your problem comes from there.

I also assume that @dognose is the answer, asking you to use SMTP better. In this way, your email is authenticated, which will help to indicate your identity.

 $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.yourdomain.com"; // sets the SMTP server $mail->Port = 26; // set the SMTP port $mail->Username = "yourname@yourdomain"; // SMTP account username $mail->Password = "yourpassword"; // SMTP account password 

If $mail->Port = 26; does not work, you can try $mail->Port = 25; .

0
source share

The SPF published by your DNS is currently invalid because you have three entries:

 # dig +short txt immortalinsurance.com "v=spf1 a mx include:smtp.secureserver.net ~all" "v=spf1 mx mx:v=spf1 a mx include:secureserver.net ~all include:secureserver.net -all" "\"v=spf1 a\"" 

The first is valid; You must remove the two second ones.

The content of this entry is correct for your domain if you send mail from 182.50.130.73. The string "mx" is not absolutely necessary, since it points to secureserver.net anyway, but it can store DNS queries on servers.

0
source share

Before sending email using mail () or SMTP, make sure you create a valid sender account in your cpanel.

 From = "noreply@immortalinsurance.com"; 

This is very important if not all messages you send are marked as SPAM and sent as spam.

Once this is done, you should configure your domain name and SPF records. Having a dedicated IP address instead of using shared hosts will also help with delivery.

Finally, check your mail with all three major email providers, such as Hotmail, Yahoo, and Gmail.

0
source share

You may have to break down the exact reason why step by step. I know that Hotmail uses a rule-based spam filter (which is pretty strict), and Gmail uses it more as a self-learning system that can explain why Gmail accepts your message and Hotmail doesn't.

Below you can check:

  • An SPF record only works in a domain when an spf record is added and only works for mail sent from the ips / domains defined in that spf. Therefore, make sure your code is executed from the server that exists in your spf.
  • Using SMTP, as suggested above, can improve manageability (but it really depends on the recipient's spam filter). If you are testing on a local server, you can use SMTP to send letters through the mail server defined in spf. Otherwise
  • If the mail server you are using is an open relay, than this could (and probably would) be the reason for adding additional spam points. Thus, make sure that you are using a closed relay (for example, the mail server you are using does not allow sending mail to unauthorized users).
  • Check if the mail server has been blacklisted ( http://mxtoolbox.com/blacklists.aspx offers a great tool);
  • Use the message headers in Gmail to find out if Gmail sees any reason to add spam to your message (Howto: https://support.google.com/mail/answer/22454?hl=en ), there you can find Does your spf work (by searching for "spf = pass"). This may also work for Hotmail if your mail is deleted in the spam folder.
  • One of the many rules that apply to a spam filter is keyword checking (which, I think, your mail contains several outages), amount of text, etc. Make sure the overall message quality is good,
  • PHPMailer uses the php mail function by default. You can change this to sendmail ( $mail->isSendmail(); probaly does not work on Windows if sendmail is not configured properly) or maybe check your php.ini settings which mail server is used (use ini_set('SMTP', 'yourhost.com'); for redefinition, but this only works on Windows, as far as I know).
0
source share

All Articles