Sending multiple emails using $to: =
Posted: Tue Jun 30, 2009 1:33 pm
Hi,
I am using someone's else code to build a "Tell a Friend" form and I need to know if there's a simple way of sending multiple emails (max. 3 emails from the form) using $to =
I don't want all the email addresses to show on the recipients inbox so I need each individual email address sent separately.
I'm using:
The above is not what I want. Obviously, I am totally new to PHP so I need someone that can give me a simple and easy solution to this issue. Thanks in advance for your time and support.
Here's the rest of the code:
I am using someone's else code to build a "Tell a Friend" form and I need to know if there's a simple way of sending multiple emails (max. 3 emails from the form) using $to =
I don't want all the email addresses to show on the recipients inbox so I need each individual email address sent separately.
I'm using:
Code: Select all
$to = $_SESSION['em1'].",".$_SESSION['em2'].",".$_SESSION['em3'];Here's the rest of the code:
Code: Select all
<?php
session_start();
if (empty($_SESSION['session-id'])) {
$_SESSION['session-id']= rand(10000000, 999999999999);
}
//if ($_SESSION['firstname']=="")
//{
//
//$_SESSION['lastname']=$lastname;
//$_SESSION['email']=$email;
?>
<?php
//define the receiver of the email
$to = $_SESSION['em1'].",".$_SESSION['em2'].",".$_SESSION['em3'];
*/
//define the subject of the email
$subject = 'Check out this site!';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: m@m.com \r\nReply-To: m@m.com";
//add boundary string and mime type specification
/*
$headers .= "\r\nContent-Type: text/html; boundary=\"PHP-alt-".$random_hash."\"";
//$headers .= "\r\nContent-Type: text/plain; boundary=\"PHP-alt-".$random_hash."\"";*/
//define the body of the message.
ob_start(); //Turn on output buffering
?>
<!----PHP-alt-<?php /*?><?php echo $random_hash; ?><?php */?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
-->
Content
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
//echo $mail_sent ? "Mail sent" : "Mail failed";
session_unset();
session_start();
?>