I’ve been trying to figure this out all day. I’m trying to create a simple back-end email interface that will allow user to enter a few fields and then mail off to several email recipients. I have figured out most of it with the exception of being able to create a link in the message. Please help.
p.s. If there are suggestions for an entirely better way to do this, I’m open to them.Thank you, james.
my code:
$subj = "Try Our New Strawberry Bagels";
$chicken = $_POST['comments'];
$message = $chicken;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
while ($row = mysqli_fetch_assoc($result))
{
$emails = $row['email'] . ",";
mail($emails, $subj, $message, $headers);
}
?>
<form action="testMail.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
Comment:<textarea name="comments"
id="comments"> </textarea>
<input type="submit" />
</form>
You’re going to be spamming the heck out of the first whose name shows up in the database results. Most likely you’d want to move the
mail()call OUTSIDE of your loop, you’ll be sending to:You’re also specifying in the mail headers that you’re sending an HTML email, so just use html to specify the link.