Total Pageviews

Tuesday, April 19, 2011

sending multiple emails in php



<php
if(isset($_REQUEST['submit']))
{
//$toadd = $_REQUEST['to'];
//define the receiver of the email
$to = $_REQUEST['to'];

$array = explode(",", $to);

foreach ($array as $k => $v)
{
    $ids= explode(",", $v);
    //echo "  ". $ids[0];
if($ids!="")
{

      if (!preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i", $ids[0]))
      {
      echo "<font color='red'>something is Invalid email id's </font>";
       }
     else{
      echo "<font color='green'> Valid Email id's </font>";
 }

}
}
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: k.v.n.krishnakumar@gmail.com\r\nReply-To:  k.v.n.krishnakumar@gmail.com";
//send the email
$mail_sent = @mail( $ids[0], $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "You have referred the following your friend email id's:'  $ids[0]' " : "Referral sending failed to:'$to' this id";
}

?>


<form method="post" action="referfndmail.php">
Invite Friends Here : <input type="text" name="to" onBlur="AjaxFunction(this.value);"><div id="msg"></div>
<input type="submit" name="submit" value="Invite" />

<form>

No comments:

Post a Comment