Mathieu Dumoulin
Mathieu Dumoulin

Reputation: 12244

Why do i have to use "-f [email protected]" in the mail() function

Recently, one of my collegue started having issues sending mail from different hosts where we were developping sites. He then remembered a long time ago that using the 5th parameter, he can pass a "-f email" in the mail() call such as:

mail('[email protected]', 'test', 'test', '', '-f [email protected]');

I'm really wondering WHY does he have to do this and what is the cause of my mail not going out when i don't use this flag.

Note that the same thing just occured again on the development server i was building, if i didn't put that 5th param, the mail were getting lost in space and never sent.


UPDATE

How can i manage to configure postfix/php to prevent me from having to use this configuration. I've been programming PHP for 11 years and i only recently started to have to do this. There must be a way to prevent this from hapenning...

Upvotes: 3

Views: 420

Answers (1)

Fredy31
Fredy31

Reputation: 2835

Seems like you have to be a trusted user on the sending server to send mail from it. Of what I've read in my research, -f just confirms that your user is a trusted user.

http://www.php.net/manual/en/function.mail.php Research -f in this page, you fall right on it.

What makes your mail doesn't go out would be that the server, not recognizing a trusted user, adds the X-Warning Header.

Upvotes: 2

Related Questions