looking for a brokerage account or IRA... click here Add To Favorites
return to index 

PHP Send Mail

Sending an email in PHP is trivial. The largest challenges are to determine the host for your server (often localhost) and inbox it at the destination. The following code will send an email in PHP.


$to = "email to send to";
$subject = "subject";
$body = "message";
if (mail($to, $subject, $body)) {
  echo("PHP Email Message sent!");
 } else {
  echo("PHP Email failed...");
 }

Protect Your Email Script!

It is easier to use an email script remotely when the script checks GET variables and accepts custom To: and From: email addresses. To protect it, make sure that the HTTP_REFERRER is from your domain, or hard-code the To: portion of the email. Also, block any IPs, except your own, the exceed a large number of requests.

Additional Interesting Articles

SQL Difference Between IS NULL and =NULL
C# MailMessage Example
PHP All Over Again
Regex C# HTML
t-SQL Cursor
Block File Leechers Using PHP

©2008 AndrewKimball.com