81123

Using PHPMailer Results in many blocked emails

I am using PHPmailer; though probably a version from 2012 - I haven't updated it for a while.

I am sending mail like this:

$mail = new PHPMailer(); $mail -> IsSMTP(); $mail -> Host = "localhost"; $mail -> Port = 587; $mail -> SMTPAuth = true; $mail -> Username = EMAIL_USER; $mail -> Password = EMAIL_PASS; $mail -> From = EMAIL_USER; $mail -> FromName = "My Company"; $mail -> AddAddress($email); $mail -> AddReplyTo('<Same as "FROM">', 'User Name'); $mail -> IsHTML(true); $mail -> Subject = 'This is my subject'; $mail -> Body = $body; $result = $mail -> Send();

I have had many emails bounce back using the above code. I even removed the body variable and just hard coded "test" in there -- so I don't think my body is the cause.

I am wondering if there are other headers that I am not using that would help or does PHPMailer take care of this behind the scene?

<strong>EDIT</strong>: I am really asking if I a missing any important header information?

Answer1:

Well I solved the issue; the code above was not the problem and works great.

In my subject, I used a phrase regarding "verify your account information" and that got it blocked on a few ISP's.

So the lesson is, your subject matters. I was looking at my php code and my body content before I realized this.

Answer2:

Some other things to note too when dealing with rejected mail:

    <li>The server you are sending mail from matters a lot. Many, like AWS, are blacklisted by default, and you need to request special permission to be able to send mail. Use a blacklist-check if you're not sure.</li> <li>Always always create an appropriate SPF txt record for your domain (in DNS). This ensures that the sending server is a verified sender for your domain.</li> <li>If you're having troubles sending mail, check the server logs to see why. Many providers (Outlook.com for example) will provide good feedback in the form of an RFC number or even a link to follow for more information.</li> <li><strong>When all else fails, use a mail gateway API like SendGrid, Mandrill, or Amazon SNS.</strong></li> </ul>

Recommend

  • Mailchimp - how can I tell if a user has unsubscribed themselves?
  • How to add some text in google piechart pieHole
  • IOS8 Text in TextField Bounces on Focus
  • a concept similar to pointers in as3?
  • LibGdx GLES2.0 cube texel stretching
  • Angular page doesn't refresh after data is added or removed
  • custom string delimiters stringtemplate-4
  • How to map Request parameter in Spring?
  • AWS-SES: Handling Bounces for Invalid ISPs
  • Python getting common name from URL using ssl.getpeercert()
  • How to access meteor package name inside package?
  • Why am I getting a “405 Method not allowed” error on “Put” operations through a WCF Resful service?
  • Why isn't obj.style.left = “200px”; working in this code?
  • uml Composition relationships to RDF and OWL
  • Can't remove headers after they are sent
  • How to convert SOAP response with xsi values to json in WSO2esb
  • Javascript, Regex - I need to grab each section of a string contained in brackets
  • How to get latest version of a artifact on Bintray using JSONP
  • Tell Git to stop prompting me for conflicts when none really exist?
  • saving file generated by TCPDF
  • Unable to decode certificate at client new X509Certificate2()
  • Install PHP intl extension on MacOS
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Play WS (2.2.1): post/put large request
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • JSON with duplicate key names losing information when parsed
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Updated Ionic CLI but shows previous version (Windows)
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • Jquery - Jquery Wysiwyg return html as a string
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • How to Embed XSL into XML
  • java string with new operator and a literal