PHP Mail headers

  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post November 2nd, 2009, 10:32 am

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?
Let's leave all our *plum* where it is and go live in the jungle ...
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 2nd, 2009, 10:32 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post November 2nd, 2009, 11:08 am

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.  
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post November 2nd, 2009, 2:01 pm

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.
Strong with this one, the sudo is.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post November 2nd, 2009, 2:22 pm

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.
Let's leave all our *plum* where it is and go live in the jungle ...
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post November 3rd, 2009, 2:09 am

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.
Let's leave all our *plum* where it is and go live in the jungle ...
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post November 3rd, 2009, 11:29 am

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.
Strong with this one, the sudo is.
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post November 4th, 2009, 12:24 am

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.
Let's leave all our *plum* where it is and go live in the jungle ...

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 137 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
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.