mail() - headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

mail() - headers

Post by Ree »

What are the recommended headers to use with mail()? I'm having a problem sending emails to some email accounts, so I wonder maybe I do not include some header which might be required?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Some of the email clients (MSN) don't allow for a blanket email from PHP's mail() function. I use phpMAILER a class available on source forge. It does a great job setting all the headers and allowing different ways of mailing besides just mail(). Hope that helps.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Date? Some ISP will bounce or even blackhole an email for lack of a date.

To, From, Reply-To, Date, X-Mailer ... that's usually all I include.

Have you check SPEW and the other blacklist for your server's IP?
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

I also use phpmailer.

The reason for the mails that are not delivered is that they are considered spam. The reason is that mail() sends the email to sendmail and sendmail sends it to the recipients. Sendmail however rewrites the header and that is bad for some spam filters. phpmailer sends the mail itself so that problem does not exist.

It is so funny that even the biggest companies send me mail directly to a trash folder because they are not aware of this problem.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Well, I'm sending mail from my Windows machine, and it uses my ISP's SMTP server for that, so it's not sendmail. I'll try adding date and X-Mailer. Btw, X-Mailer - it indicates what was used when sending mail? What should I include there?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

yeah,a lot of my e-mails get blackholed too...even with phpmailer....i give up on getting them all through. I'm happy with a 50% success rate. LOL
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

If your mails are rejected even with phpmailer means that your mail setings are incorrect or that there is no mx-record for your mail sending machine. Many ISP check if they can reroute to the machine. if they can't the mail is moved to spam or rejected.
Post Reply