Introduction
Over the history of the Internet, email systems have become more complex and more varied, and the standards for email exchange have developed accordingly.
Unfortunately, not all email systems operate according to the Internet standards. This means that programs such as FormMail must cater for non-standard as well as standards-compliant email servers.
One area in which there is quite a variety of operation is in the concept of the From Address of an email and the Sender of the email.
Some email servers will accept the From Address as being the Sender, and some deduce the Sender automatically, and some require the Sender to be specified explicitly.
In general, the Sender is the actual originator of the email message. The From Address, in contrast, is simply a header line in the email that may or may not be taken to mean anything. The From Address can often be left out completely. Spammers can easily spoof the From Address. ISPs try to ensure that spammers cannot spoof the Sender.
The following information provides the exact rules that FormMail uses for these two email concepts. When reading, bear in mind that FormMail attempts to make a form submission look like it has come from the user filling in the form, even though the email is actually being sent by the webserver software on your server.
This means that FormMail attempts to set the From Address to the value of the "email" field specified on your form and entered by the person filling in and submitting the form.
FormMail attempts to set the From Address this way to assist you. In most cases, it's helpful to you that, when you receive a form submission email, its From Address is shown as the person submitting the form.
Detailed Description
The following sections describe the exact rules used by FormMail for setting the From Address and the Sender of the emails it sends.
For form results...
The From Address for form results is usually the email address entered by the user on the form (the "email" field). If you set FromAddr in mail_options, the "From" address is set to this value and the Sender is also set to this value. If you do not set FromAddr, then the "From" address is set to the "email" field (plus the "realname" field) from the form and no Sender is specified by FormMail.
From version 8.05 of FormMail, if you specify FIXED_SENDER, FormMail sets the Sender to the value you've specified.
For alert messages...
Both From Address and Sender are set according to the rules for the FROM_USER configuration.
Logic Process
Following is a complete description of the emailing logic. This logic is quite complicated because different servers have different and, often, conflicting requirements.
We define these concepts:
Sender |
is an email address that is deemed to be sending an email. |
From Address |
is an email address that is deemed to be the "From Line" (the From: line in the header) in an email being sent. |
For Form Results (not Alert Messages and Auto Responses)
If the "FromAddr" feature is used by the form, then:
- Set Sender to the FromAddr value; and
- Set From Address to FromAddr value.
If the "FromAddr" feature is not used by the form, then:
- If SET_SENDER_FROM_EMAIL is set to true, then Set Sender to the "email" value from the form, otherwise, leave Sender unset; and
- Set From Address to the realname + email fields from the form.
From version 8.05 of FormMail, if FIXED_SENDER is set and is not empty, then set the Sender to the value of FIXED_SENDER.
For Alert Messages (not Form Results)
if FROM_USER (in FormMail's configuration) is set and is not empty, then:
if it has the value "NONE", then: do not set either Sender or From Address values
otherwise:
set Sender and From Address values to the FROM_USER value;
if FROM_USER is not set or it's empty, then: set Sender and From Address values to a fake address on the server (FormMail@domain).
For Auto Responses (not Form Results or Alert Messages)
if the "FromAddr" feature is used in the "autorespond" field, then:
set Sender and From Address values to the FromAddr value
otherwise:
if FROM_USER is set and is not empty, then:
if it has the value "NONE", then: do not set either Sender or From Address values
otherwise:
set Sender and From Address values to the FROM_USER value; if FROM_USER is not set or it's empty, then: set Sender and From Address values to a fake address on the server (FormMail@domain).
For all emails (form results, alerts, auto responses)
If SENDMAIL_F_OPTION is true:
if Sender is set, specify its value with the -f option in the mail command.
If INI_SET_FROM is true:
if Sender is set, specify its value to the "sendmail_from" PHP option.
In every case:
set the "From:" line of the email header to the value of the From Address.