0% found this document useful (0 votes)
391 views3 pages

Send E-Mail To Multiple E-Mail (Persons) With PHP

This document provides code to send an email to multiple recipients with PHP. It includes: 1) JavaScript form validation to validate the sender and recipient email fields 2) A PHP form to collect the sender's email, multiple recipient emails separated by commas, and message content 3) PHP code to send the email upon form submission, splitting the recipient field into an array and sending to each email address individually.

Uploaded by

Gunjan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
391 views3 pages

Send E-Mail To Multiple E-Mail (Persons) With PHP

This document provides code to send an email to multiple recipients with PHP. It includes: 1) JavaScript form validation to validate the sender and recipient email fields 2) A PHP form to collect the sender's email, multiple recipient emails separated by commas, and message content 3) PHP code to send the email upon form submission, splitting the recipient field into an array and sending to each email address individually.

Uploaded by

Gunjan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Topic - Send E-mail to Multiple Person(E-mail) with Php

Send E-mail to Multiple Person(E-mail) with Php

<html>
<head>
<title> Send E-mail to Multiple Person(E-
mail) with Php
</title>
</head>
<body bgcolor="#666666">
<!--Email Validation START -->
<script language="javascript">
function
validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{
alert(alerttxt);return false
}
else
{
return true
}
}
}
</script>
<!--Email Validation END -->

<script language="javascript">
function checkdata()
{
if(document.emailpost.from.value=="")
{
alert("Form field should not be blank! Please Enter your Email id");
document.emailpost.from.focus();
return false;
}
else if(document.emailpost.to.value=="")
{
alert("To field should not be blank! Please Enter Destination Email id ");
document.emailpost.to.focus();
return false;

}
else if(document.emailpost.from.value!="")
{
if (validate_email(eval("document.emailpost.from"),"Not a valid e-mail

Code By Gunjan Kumar (gunjankumarverma@gmail.com) Paga - 1


Topic - Send E-mail to Multiple Person(E-mail) with Php

address!")==false)
{
document.emailpost.from.focus();
return false
}
}

else
return true;
}
</script>
<form name="emailpost" action="test.php" method="post" onSubmit="return checkdata()">
<table cellpadding="5px" cellspacing="0px" style="font-size:12px; font-family:Verdana, Arial,
Helvetica, sans-serif; border:7px solid gray; background:#eeffee" width="500px" align="center">
<tr>
<td colspan="2" bgcolor="gray" style="color:#FFFFFF; font-weight:bold; padding:10px"> Send E-
mail to Multiple Person(E-mail) with Php
</td>

</tr>
<tr>
<td>Enter Your Email id</td>
<td align="right"><input type="text" name="from" size="40" value="<? echo $_POST["from"];?
>"/></td>
</tr>
<tr>
<td colspan="2">Enter Your Friend Email id(s) </td>
</tr>
<tr>
<td colspan="2" align="right"><textarea rows="5" cols="50" name="to" value="<? echo
$_POST["to"];?>"></textarea>
<br />
Enter Emails Speparated by colon(,)</td>
</tr>
<tr>
<td colspan="2">Enter Your Message</td>
</tr>
<tr>
<td colspan="2" align="right"><textarea rows="5" cols="50" name="message" value="<? echo
$_POST["subject"];?>"></textarea></td>
</tr>
<tr>

<td colspan="2" align="right"> <input type="submit" name="action" value="Send Email"


style="background:#333333; color:#FFFFFF; border:1px solid gray" onClick="return checkdata()" />
<input type="reset" value="Clear" style="background:#333333; color:#FFFFFF; border:1px solid
gray" /></td>
</tr>
<tr>

Code By Gunjan Kumar (gunjankumarverma@gmail.com) Paga - 2


Topic - Send E-mail to Multiple Person(E-mail) with Php

<tr>
<td colspan="2">
<div style=" background:white; padding:5px; color:#666666">
<?
if($_POST["action"]=="Send Email")
{
$to=$_POST["to"];
$from_email=$_POST["from"];
$message=$_POST["message"];
$to_single = split ("\,", $to); //splite email into array
$to_single_count_index=count($to_single); //count total index of array to_single
echo "<font color='red'>Email send to:</font><font color='green'> ";
for($i=0;$i<$to_single_count_index;$i++)
{
$to_s=$to_single[$i];

$headers = "From: $from_email\r\nReply-To: $from_email\r\n";


$headers .= "Content-type: text/html\r\n";
$mail_sub="Test Email";
mail($to_s,$mail_sub,$message,$headers);
echo $to_s,", ";
}

}
?>
</font>
</div>
</td>
</table>
</form>
</body>
</html>

Thanks
Gunjan Kumar
gunjankumarverma@gmail.com
http://gunjankumarverma.blogspot.com
http://bihar.infozones.in

Code By Gunjan Kumar (gunjankumarverma@gmail.com) Paga - 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy