Mailer problem?

Hello. Just signed up today and almost as new to PHP, so please forgive any basic ignorance!

I run a PHP Mailer for a form on my website which most of the time runs perfectly well.
However, sometimes when we test it (from various email adresses and ISPs), the email generated to us submitting the form data is rejected with the message “SMTP server response: 554 <our email address>: Recipient address rejected” … etc.

I cannot understand why this is happening intermittently, especially as no changes are being made to the code, so we contacted out server provider to see if this was a server problem.

Without any explanation (as they “do not support scripting issues”!), they have suggested that I need to add a “-f” on the variable or email address where the email is being sent from, and they gave me the following example:

mail("$to",“Subject”,“Content”,“From:$from”,"-f$from")

I have no idea what this is supposed to do and cannot find any reference to it anywhere, but maybe I’m just looking in the wrong places! Reluctant to change code when I don’t know why!

Any help would be greatly appreciated.

Many thanks.

Suzyq :slight_smile:

You’re using 5th parameter in the mail() function, which is referred as additional_parameters in the PHP online manual:

The [i]additional_parameters[/i] parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a ‘X-Warning’ header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

Source: http://php.net/manual/en/function.mail.php
(See also user comments at bottom of this url for examples of using -f option)

Sponsor our Newsletter | Privacy Policy | Terms of Service