note 57715 added to ref.mail

From: Date: Wed, 12 Oct 2005 06:22:43 +0000
Subject: note 57715 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-96882@lists.php.net to get a copy of this message
I too have had someone trying to use my site to send spam email by injecting headers and using a bcc: address. One way to stop this is by creating a multipart message as shown in the code below. Note that to pass the 'antispam' checks of hotmail etc. you should set up automailer@mysite.com as a "real" email account, so that if anyone checks it'll actually be there. <?php // YOU CAN SET THESE ALL UP YOURSELF DEFINE("NAME","MySite"); DEFINE("RETURN_ADDRESS","automailer@mysite.com"); $contactemail="personToContact@their-email.com"; $contactname="Person to Contact"; $subject="The subject"; $messageNotHTML="This is the message in text format"; // THE MAIN FUNCTIONALITY $boundary = md5(time().rand(1,100)); $headers = "MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=\\"{$boundary}\\" X-Mailer: PHPmailer From: \\"".NAME."\\" <".RETURN_ADDRESS."> "; $message = " --{$boundary} Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable $messageNotHTML --{$boundary}-- "; $didmail = mail("\\"".$contactname."\\" <".$contactemail.">", $subject, $message, $headers); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57715 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57715&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57715&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96882) next »