How do I send e-mail from PHP scripts?
You can send e-mail from PHP scripts (as long as you follow our anti-spam policies, described below).
When you use PHP to send e-mail, you can specify the “bounce” (“Return-Path”) address to make sure that undeliverable messages are sent where you expect. See our page explaining the “Return-Path” for more information.
If you want to specify a bounce address, your script should use "-f something@example.com" (where “something“ is the address you want to use, of course) as the fifth parameter to PHP’s mail() function. Here’s one example of doing that:
$from_address = "something@example.com"; mail ($to, $subject, $body, "From: $from_address", "-f $from_address");
Doing this makes sure that “bounces” go to the correct address. The address must end with your domain name to be accepted by our mail servers.
The PHP mail() function documentation has more details explaining the various mail() parameters.
What if I don’t specify a bounce address?
If you don’t specify a bounce address at all, that will work, too. The bounce address will default to a special address that forwards to the administrative contact address we have on file for your account.
E-mail script policies
We do have some restrictions on the type of e-mail that can be sent from scripts on the server.
First of all, please read our spam policy and make sure your messages don’t violate it.
Once you’ve read that, it’s okay to send e-mail from a script without asking for any further permission as long as the script can only send messages back to you (for example, the results of feedback forms), and your script meets this requirement:
- All messages sent must have an “envelope sender” address (aka “return address”, “bounce address” or “Return-Path”) that ends with your domain name. We don’t allow scripts to send messages with return addresses of domain names not hosted with us, such as aol.com, hotmail.com, etc.
To prevent strangers from abusing your script to send spam or harass others, you do have to ask our prior permission before using scripts that can send e-mail to other people. Our additional requirements for giving permission are:
- If the script adds the recipient to an ongoing mailing list, it must use confirmed opt-in policies and maintain records of how each recipient confirmed the subscription request.
- If the script is not a mailing list system (i.e., it sends one-time messages), it must prevent potential spammers from specifying both the recipient address and any of the message subject or body.
To get approval for a script that sends e-mail to other people, just upload it to your Web site and contact us by ticket or e-mail telling us the name of the script and asking for permission to use it. If you are using a mailing list you have already compiled, please provide details of how you confirmed the subscription for each existing recipient address (for example, by sending us the date and IP address used to confirm each subscription request).
