Jump to content

Sending HTML emails


SCook

Recommended Posts

function sendVideoEmail($mID, $id) {
global $access;

// Get the member's email and name
$query = "select first_name,email from members where id = $mID;";
$result = mysql_query($query, $access);
$mem = mysql_fetch_row($result);

// Get the email data
$query = "select * from adv_mail where id = $id;";
$result = mysql_query($query, $access);
$mail = mysql_fetch_array($result);

// Get the advetisers contact info
$query = "select * from advertisers where id = " . $mail["aID"] . ";";
$result = mysql_query($query, $access);
$adv = mysql_fetch_array($result);

// Compose the email
$headers   = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: $mem[1]\n";
$headers .= "From: www.stirfrytv.com\n";

$body = "
	<html>
	<head>
	<title>Stir Fry TV Message,/title>
	</head>
	<body>
	<table width = 100% border = 0>
		<tr>
			<td>Hello, $mem[0]</td>
		</tr>
		<tr><td height = 20></td></tr>
";

if ($mail["image_placement"] == "t") {
	$body .= "
		<tr>
			<td align = 'center'>
				<img src = 'http//65.254.38.55/~river/emails/$id.jpg' border = 0>
			</td>
		</tr>
		<tr><td height = 10></td></tr>
		<tr>
			<td>" . $mail["msg"] . "</td>
		</tr>
	";
} elseif ($mail["image_placement"] == "b") {
	$body .= "
		<tr>
			<td>" . $mail["msg"] . "</td>
		</tr>
		<tr><td height = 10></td></tr>
		<tr>
			<td align = 'center'>
				<img src = 'http//65.254.38.55/~river/emails/$id.jpg' border = 0>
			</td>
		</tr>
	";
}

$body .= "
		<tr><td height = 20></td></tr>
		<tr>
			<td>
";

$body .= "<b>" . $adv["company"] . "</b><br>";
$body .= $adv["street_address"] . "<br>";
if ($adv["address_line_2"] != "") {
	$body .= $adv["address_line_2"] . "<br>";
}
$body .= $adv["city"] . ", " . $adv["state"] . " " . $adv["zip"] . "<p>";
$body .= "Phone: <b>" . $adv["phone"] . "</b><br>";
$body .= "E-mail address: <b><a href = 'mailto:" . $adv["email"] . "'>" . $adv["email"] . "</a></b>";

$body .= "
			</td>
		</tr>
	</table>
	</body>
	</html>
";

if (!mail($mem[1], $mail["subject"], $body, $headers)) {
	return true;
}
}

Link to comment
https://forums.phpfreaks.com/topic/138554-sending-html-emails/#findComment-724447
Share on other sites

I don't understand why you have this

$headers .= "To: $mem[1]\n";

 

Then,

if (!mail($mem[1], $mail["subject"], $body, $headers))

 

Wouldn't it be simpler to define the $to without the header?

 

$to = $mem[1];

if ($to, $mail["subject"], $body, $headers))

 

Link to comment
https://forums.phpfreaks.com/topic/138554-sending-html-emails/#findComment-724559
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.