|
|
|
|
|
|
| |
|
<?
// Written by my working partner, Marc Jones (edm-i.com) who
// says this function should augment the php mail() function
// hacker/spammer safe wrapper for php mail() function that will allow plain text and mixed html email
// version 1 does not handle attachments - I'll work on that
function send_email($to, $fromaddr, $fromname, $subject, $message_text, $message_html = "")
{
// to prevent spammers/hackers from utilising your html2server email form
// this type of hacking is called "header injection" where the spammer will call your
// script with the subject or message containing more header information before the message
// allowing them to send as many mails as they like, and blacklisting your mail server as a spammer
// they mostly change the headers, and add cc, and bcc headers.
// The best way to stop this is to check for headers and remove them!
$subject = preg_replace("/\nfrom\:.*?\n/i", "", $subject);
$subject = preg_replace("/\nbcc\:.*?\n/i", "", $subject);
$subject = preg_replace("/\ncc\:.*?\n/i", "", $subject);
$message_text = preg_replace("/\nfrom\:.*?\n/i", "", $message_text);
$message_text = preg_replace("/\nbcc\:.*?\n/i", "", $message_text);
$message_text = preg_replace("/\ncc\:.*?\n/i", "", $message_text);
$message_html = preg_replace("/\nfrom\:.*?\n/i", "", $message_html);
$message_html = preg_replace("/\nbcc\:.*?\n/i", "", $message_html);
$message_html = preg_replace("/\ncc\:.*?\n/i", "", $message_html);
// create additional_parameters - this ensures that the RETURN-PATH will be properly set
// saving the mail from being rejected by the destination mail server as spam
// known servers that reject if RETURN-PATH domain does not match the from domain include
// gmail, hotmail, aol, excite, yahoo, btinternet
// most spam killers will also regard emails with
$additional_parameters = "-f $fromaddr";
// create additional_headers
$headers = "From: $fromname <$fromaddr>\r\n";
// specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
// deal with html messages
if($message_html != "")
{
// unique boundary
$boundary = uniqid("sometext");
// tell e-mail client this e-mail contains alternate versions
$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";
// plain text version of message
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: 7 bit\r\n\r\n";
$body .= $message_text."\r\n\r\n";
// HTML version of message
$body .= "--$boundary\r\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: t bit\r\n\r\n";
$body .= $message_html."\r\n\r\n";
}
// deal with plain text only messages
if($message_html == "")
{
// tell e-mail client the content type
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
// the plain text message
$body = $message_text;
}
// send message
return mail($to, $subject, $body, $headers, $additional_parameters);
}
?> | | |
|
| Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | | | Creates a CAPTCHA image in PHP, which displays 5 numbers stored in a session. Categories : PHP, GD image library, Form Processing, Security | | | A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP, PHP Classes, Security, GD image library, Security | | | Forms protected from XSS attacks (FOPAXSS) Categories : PHP, PHP Classes, Form Processing, Security | | | send php mail with form data and attachment. Categories : PHP, Email, Mail, Form Processing | | | Protect your mailto: email addresses from bots - pure PHP Categories : PHP, Email, Security | | | addslashes automatically to $_POST variables Categories : PHP, Form Processing, Security | | | Protect your email links from being spidered by spam email robots! Categories : PHP, Security, Mail, Email | | | cPanel Email Accounts Creator Categories : PHP, PHP Classes, Email, Form Processing, Web Services | | | Customer feedback or simple emailer - A PHP script that enables your visitors to send you emails.
Categories : PHP, Email, Form Processing | | | PHP MIME Decoder. This class decodes Mime Encoded email message.
Attachments are stored in a director. Works with Multipart/alternative,
multipart/mixed etc.
see http://p3mail.com for example. Categories : PHP, PHP Classes, Email | | | FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps | | | Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users). Categories : Algorithms, Email, PHP | | | Passgen: Automatically generate mixed case alpha numeric passwords Categories : PHP, Security | | | Protect your mailto: email addresses from bots Categories : PHP, Email, Java Script | |
| | | | Roland Booth wrote :1361
Thanks for this. Arrive just when i needed it
| |
|
|