PHP - how do i send multiple personalized emails

Asked By Olusegun A. on 05-Apr-10 05:34 PM
Hello Fellas,

Am designing a sign and there is a page (INVITE FRIENDS) where members can invite there friends. All the member has to do is just to enter the friends name and email into the form and click invite. the form is below;

<form id="form1" name="form1" method="post" action="<?php echo $_SESSION['PHP_SELF']; ?>">
<table width="500" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<th width="26" scope="col" id="heading4"><div align="center"></div></th>
<th width="182" scope="col" id="heading4"><div align="left"> Names</div></th>
<th width="262" scope="col" id="heading4"><div align="left"> Email Addresses </div></th>
</tr>
<tr>
<td class="style5"><div align="center">1.</div></td>
<td class="style5"><label>
<input name="name1" type="text" id="name1" />
</label></td>
<td class="style5"><label>
<input name="email1" type="text" id="email1" size="40" />
</label></td>
</tr>
<tr>
<td><div align="center">2.</div></td>
<td><input name="name2" type="text" id="name2" /></td>
<td><input name="email2" type="text" id="email2" size="40" /></td>
</tr>
<tr>
<td class="style5"><div align="center">3.</div></td>
<td class="style5"><input name="name3" type="text" id="name3" /></td>
<td class="style5"><input name="email3" type="text" id="email3" size="40" /></td>
</tr>
<tr>
<td><div align="center">4.</div></td>
<td><input name="name4" type="text" id="name4" /></td>
<td><input name="email4" type="text" id="email4" size="40" /></td>
</tr>
<tr>
<td class="style5"><div align="center">5.</div></td>
<td class="style5"><input name="name5" type="text" id="name5" /></td>
<td class="style5"><input name="email5" type="text" id="email5" size="40" /></td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Invite Friends" />
</p>
</form>

assuming a member named Felix entered filled the form as below;

1. Mike (mike@yahoo.com)
2. Bond (bond@gmail.com)
3. Benita (benita@hotmail.com)
4. Oliver (oliver@yahoo.co.uk)
5. Annabel (annabel@hotmail.com)

The message is like this;

From: http://www.mysite.com
To: [friend's email]
Hello [Friend's Name]
Your friend Felix found our site interesting and want you to check it out. etc


I know I can use MAIL($to, $subject, $message, $header)
The problem is that, how do i make the message to go to each email and echo the name of the email owner? Eg,

From: http://www.mysite.com
To: mike@yahoo.com
Hello Mike
Your friend Felix found our site interesting and want you to check it out. etc

From: http://www.mysite.com
To: bond@gmail.com
Hello Bond
Your friend Felix found our site interesting and want you to check it out. etc

From: http://www.mysite.com
To: benita@hotmail.com
Hello Benita
Your friend Felix found our site interesting and want you to check it out. etc

From: http://www.mysite.com
To: oliver@yahoo.co.uk
Hello Oliver
Your friend Felix found our site interesting and want you to check it out. etc

From: http://www.mysite.com
To: annabel@hotmail.com
Hello Annabel
Your friend Felix found our site interesting and want you to check it out. etc

Please help
Regards

Tamer Hatoum replied to Olusegun A. on 06-Apr-10 11:05 AM
Hello;
after checking the the multiple names , you can get an array and ckeck inside a loop to check in if the selected box list is checked then select the email to slected index ID...
regards...
Darren Mitchell replied to Olusegun A. on 14-Apr-10 10:13 AM
Hi.
I hope you will find the solution to your issue at php tutorials.