Hey everyone, I'm just beginning to dabble in php and im in dire need of help. I need to generate html email from a flash movie, and ive got it working fine -- as long as im sending text only -- when i try to send an entire html email with images and formatted text though, it just never gets to the mailbox. Can someone pls take a look at this code an tell me why im an idiot?
<?
$ToEmail = "$recemail";
##$ToName = "SkinSpa";
$ToSubject = "$sendemail has sent you a VirtualSpa Mud Bar Gift Certificate from SkinSpa.com";
$EmailBody = "
<html>
<head>
</head>
<body bgcolor="#596884">
<table width="500" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle"><img src="http://www.skinspa.com/vspa/logob.gif" width="155" height="110"></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="http://www.skinspa.com"><img src="http://www.skinspa.com/vspa/receive1.jpg" width="500" height="300" border="0"></a></td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif"> $usrmessage </font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif">To
redeem this certificate, please call (818) 995-3888<br>
to make an appointment.</font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$Message = $EmailBody;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, $headers, "From: "$sendemail");
?>
HTML email wont send images, pls help!
Moderator: General Moderators
-
VMAXStudios
- Forum Newbie
- Posts: 2
- Joined: Sat May 15, 2004 1:50 am
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
Use the heredoc syntax instead and you won't need to escape the quotes:
You also need another carriage-return-line-feed after the final header.
Have you thought about a plain text alternative?
Code: Select all
<?
$ToEmail = "$recemail";
##$ToName = "SkinSpa";
$ToSubject = "$sendemail has sent you a VirtualSpa Mud Bar Gift Certificate from SkinSpa.com";
$EmailBody = <<<EMAIL
<html>
<head>
</head>
<body bgcolor="#596884">
<table width="500" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle"><img src="http://www.skinspa.com/vspa/logob.gif" width="155" height="110"></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="http://www.skinspa.com"><img src="http://www.skinspa.com/vspa/receive1.jpg" width="500" height="300" border="0"></a></td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif"> $usrmessage </font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif">To
redeem this certificate, please call (818) 995-3888<br>
to make an appointment.</font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
EMAIL;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$Message = $EmailBody;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, $headers, "From: "$sendemail");
?>Have you thought about a plain text alternative?
Code: Select all
Content-Type: multipart/alternative; boundary="$boundary"\r\n\r\n
--$boundary\r\n
Content-Trnasfer-Encoding: 8bit\r\n
Content-Type: text/plain; charset="us-ascii"\r\n\r\n
$your_plain_text_message_here\r\n
--$boundary\r\n
Content-TransferEncoding: 8bit\r\n
Content-Type: text/html; charset="us-ascii"\r\n\r\n
$your_html_message_here\r\n
--$boundary---
VMAXStudios
- Forum Newbie
- Posts: 2
- Joined: Sat May 15, 2004 1:50 am
Sorry folks, im really a noob. I still can't get it to work. Have I altered this somehow incorrectly?
also, can someone please tell me what it means to "escape a quote"?
Code: Select all
<?
$ToEmail = "$recemail";
##$ToName = "SkinSpa";
$ToSubject = "$sendemail has sent you a VirtualSpa Mud Bar Gift Certificate from SkinSpa.com";
$EmailBody = <<<EMAIL
<html>
<head>
</head>
<body bgcolor="#596884">
<table width="500" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle"><img src="http://www.skinspa.com/vspa/logob.gif" width="155" height="110"></td>
</tr>
<tr>
<td align="center" valign="middle"><a href="http://www.skinspa.com"><img src="http://www.skinspa.com/vspa/receive1.jpg" width="500" height="300" border="0"></a></td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif"> $usrmessage </font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td align="left" valign="middle"><font color="#CCCCCC" size="2" face="Verdana, Arial, Helvetica, sans-serif">To
redeem this certificate, please call (818) 995-3888<br>
to make an appointment.</font></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
</tr>
</table>
<p> </p>
</body>
</html>
EMAIL;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$Message = $EmailBody;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, $headers, "From: ".$FirstName." <".$email.">");
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
http://www.php.net/manual/en/function.mail.php wrote:Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 this parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE if you're trying to use it.
Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly.
Note: The to parameter should not be an address in the form of "Something <someone@example.com>". The mail command may not parse this properly while talking with the MTA (Particularly under Windows).