How do I send email from PHP scripts?
You can send email from PHP scripts (as long as you follow our anti-spam policies, described below).
When you use PHP to send email, 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 email@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 = "firstname.lastname@example.org"; 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
What if I don’t specify a bounce address?
If you don’t specify a bounce address at all, the message will still be delivered.
However, the bounce address will default to a special address that forwards to the administrative contact address we have on file for your account), and some recipients may see notices like “via tigertech-hosted-site.net” in their mail headers.
If you can’t change your script, you can set a different default sending address based on your own domain name.
E-mail script policies
We do have some restrictions on the type of email that can be sent from scripts on the server.
It’s okay to send email from a script as long as the script can only send messages to you (for example, the results of feedback forms).
However, to prevent strangers from abusing your script to send spam or harass others, you do have to follow specific rules and ask our permission before using scripts that can send email to other people. Our requirements for giving permission are:
- If your script sets a custom “envelope sender” address (aka “return address”, “bounce address” or “Return-Path”), that address must end with your domain name. See our page explaining the “Return-Path” for more information.
- The messages you send must not violate our spam policy. In particular, if the script adds the recipient to an ongoing mailing list, it must verify each address using a “confirmed opt-in” or “double opt-in” system, must maintain records of how each recipient verified the subscription request, and must include unsubscribe instructions with each message it sends.
- 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. It should also use a CAPTCHA to prevent “bots” from filling out the form with other people’s addresses, unless the form already does some kind of “prove you're human” test as a side-effect (such as an order form that requires a credit card number).
To get approval for a script that sends email to other people, just upload it to your website and contact us, telling us the name of the script and asking for permission to use it. If you’re using a mailing list you have already compiled, please provide details of how you verified each address (for example, by sending us the date and IP address used to confirm each subscription request).
Can I use SMTP from PHP?
You should avoid using SMTP mail submission from PHP scripts running on our servers if possible; always use the built-in PHP mail function if the script supports it. For example, we don’t recommend WordPress plugins designed to make your mail get sent via SMTP.
There's a very good reason for this. If you use SMTP, your script will fail to send email if the SMTP server is temporarily unavailable due to scheduled maintenance. That's because SMTP is designed for sending mail between mail servers that know how to try again a few minutes later if the receiving mail server is unavailable, but your script won't know how to do that.
In contrast, PHP mail is designed as a way for scripts to submit outgoing mail to mail servers. It uses the server’s “sendmail” function, which accepts the mail from your script, stores it, and tries delivering it to the SMTP server. This normally takes just a fraction of a second, but sendmail will happily keep trying for as long as necessary to successfully deliver your messages. Using it makes your script much more reliable.
Copyright © 2000-2019 Tiger Technologies LLC