tags:

views:

51

answers:

3

Hi, I have an application that sends verification emails to people account email address, but sometimes it goes into their spam filter, after an analysis on the email we found that one of the reasons is because of having no user agent name.

is there a way to set this using php's default email sender?

thanks

+1  A: 

The only user agent setting in PHP is user_agent, but this setting is only used for HTTP requests. You can pass additional headers to the mail() function to accomplish this:

mail(
    '[email protected]',
    'Subject',
    'Message Body',
    "From: [email protected]\r\nX-Mailer: PHP"
);
Jordan Ryan Moore
A: 

You need to set a header that identifies your program. As you can see in the php manual for mail the fourth paramter allows you to include headers. The RFC identifies both "Mailer", "X-Mailer" and "Sender" as the agents, so which one to use I will leave up to you (wikipedia notes that X-Mailer is ofte used by clients).

An example:

$headers = "X-Mailer: MyApp\r\n";
$succcess = mail(€to, $subject, $message, $headers);
Christian P.
A: 

I wrote a exhaustive "what to do if auto-generated mails get swallowed by the spam filter" a few years ago. Unfortunately, it's in german, but one aspect I remeber from the research I did for it is that spam filters can react very pickily to X-Mailer signatures that point towards a programming language / script / bulk E-Mailer. You may want to pretend to be a normal mail program like Outlook to make sure the E-Mail gets through.

Pekka
this is what i would like to get information about, how would one go about this?
Lysergic9
If I send an E-Mail to myself using Thunderbird, I get "User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)" in the header. Outlook is sure to have a similar attribute. You might want to leave X-Mailer aside, try one of these and see whether they get through better.
Pekka