PHP Mail headers

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

I have the following mail headers:

Code: [ Select ]
$headers = "MIME-Version: 1.0\n";
  $headers .= "Content-type: text/html; charset=iso-8859-1\n";
  $headers .= "X-mailer: php\n";
  $headers .= "From: \"{$from_name}\" <{$from_email}>\n";
  $headers .= "Return-Path: {$from_email}\n";
  1. $headers = "MIME-Version: 1.0\n";
  2.   $headers .= "Content-type: text/html; charset=iso-8859-1\n";
  3.   $headers .= "X-mailer: php\n";
  4.   $headers .= "From: \"{$from_name}\" <{$from_email}>\n";
  5.   $headers .= "Return-Path: {$from_email}\n";


And these mails are being picked up as spam ... What else do I need to add to fix this issue?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23455
  • Loc: Woodbridge VA

Post 3+ Months Ago

Are you getting NDR's? If so is the NDR "smtp;550 5.6.0 Lone CR or LF in headers"?

If it is, check out see RFC2822 section 2.2.
http://www.rfc-archive.org/getrfc.php?rfc=2822

Quote:
Header fields are lines composed of a field name, followed by a colon
(":"), followed by a field body, and terminated by CRLF. A field
name MUST be composed of printable US-ASCII characters (i.e.,
characters that have values between 33 and 126, inclusive), except
colon. A field body may be composed of any US-ASCII characters,
except for CR and LF. However, a field body may contain CRLF when
used in header "folding" and "unfolding" as described in section
2.2.3. All field bodies MUST conform to the syntax described in
sections 3 and 4 of this standard.


Also in php mail, to, subject and message are required. Other headers are optional
http://php.net/manual/en/function.mail.php

Also looking at a couple of the examples, the carriage return is concatenated . I don't know if that makes a difference.
PHP Code: [ Select ]
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
  1. // To send HTML mail, the Content-type header must be set
  2. $headers  = 'MIME-Version: 1.0' . "\r\n";
  3. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  4.  
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Reminding your users to add an exception for mail from you is all you can really do to keep from being dumped in their spam bin. If there were some magical header you could always add/omit to keep yourself out of the spam bin that would pretty much defeat the entire purpose of spam filters in the first place.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

Yeah joebert I hear you. What really sucks is that my client doesn't ... These people have absolutely no understanding of the internet. It's difficult for me to try and get it through to them that it just isn't that simple. hehe.

@atno: Thanks for the link, I can't view that page (RFC) but I found it by searching google.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

Sorry that I wasted your time guys ... I forgot to add the semi-colon after each of the lines ... What a daft moment ... Thanks anyway guys.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

A syntax error actually lets the emails get sent instead of giving you an notice ? :scratchhead:

Wow, imagine if someone missed a single semi-colon on a mailing list with a sizable number of recipients. Every provider on the Internet would end up flagging you.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

Yeah, the funny thing is, these mails were getting sent off our dedicated server at work ... our email addresses on ther domains on the same server were getting it fine, but then even yahoo and hotmail were receiving the mails just fine, but the client wasn't receiving the mails. It's a really strange situation ... I really don't understand how email really works.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 110 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.