我想發送一個電子郵件模板與生成的PHP圖像。當我在服務器上打開文件時,我能夠生成圖像,但是當我發送電子郵件時,我無法生成圖像。PHP不工作的電子郵件模板
<?php
//change this to your email.
$to = "Brian Chiem <[email protected]>";
$from = "Performance <[email protected]>";
$subject = "Test email - Performance Summary";
//begin of HTML message
$message = <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>psdtoweb120715EmailSummary1195.psd</title>
<link type="text/css">
</head>
<style >
{
body, table, tr, td, p {
margin: 0;
padding: 0;
}
</style>
<body margin = "0" padding = "0">
<table width = "100%" height = "826"margin = "0" padding = "0">
<tr margin = "0" padding = "0">
<td width = "25%" margin = "0" padding = "0"> </td>
<td margin = "0" padding = "0">
<table margin = "0" padding = "0" width = "612" height = "826" background= "http://piqdev.myperformanceiq.com/brian/images/bckgrnd1.png" style="background-repeat:no-repeat;>
<tr margin = "0" padding = "0">
<td valign = "top"> <p style= "margin:0; padding-left: 20px; text-transform: uppercase;font-size: 30pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;" >Steve.b</p></td>
<td colspan = "2" valign = "top" align = "right" style = "padding-left:100px; padding-right: 10px"><p style= " display: relative;margin:0; padding-top: 5px;font-size: 12pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"> Result summary for: <span style= "margin:0; font-size: 15pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"> 8/20/15</span><br/>55 Minutes (6:00 am - 6:55am) </p></td>
</tr>
<tr margin = "0" padding = "0" height = "10%" display = "relative">
<td valign = "top" margin = "0" padding = "0" style= "margin:0; padding-bottom: 60px;font-size: 70pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-left: 100px; padding-bottom: 390px; " >500 </p></td>
<td valign = "top" margin = "0" padding = "0" style= "margin:0; font-size: 40pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-left: 50px; padding-top: 20px;padding-bottom: 10px;">300 <br/><div style = "padding-left: 55px;padding-top:0px; ">600 </div></td>
<td valign = "top" margin = "0" padding = "0" style= "margin:0; font-size: 40pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-top: 20px; padding-left: 20px; padding-right: 42px; ">200 <br/> <div style = "padding-left: 15px; padding-top:13px; font-size:35pt;" >3/12 </div></td>
</tr>
<tr>
<td>
<img src= "<?php imagefilledrectangle.php>>
</td>
</tr>
</table>
</td>
<td width = "25%"> </td>
</tr>
</table>
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
// echo $message;
//options to send to cc+bcc
//$headers .= "Cc: [email][email protected][/email]";
//$headers .= "Bcc: [email][email protected][/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
引用的PHP文件是
<?php
// Create a 55x30 image
$im = imagecreatetruecolor(55, 30);
$white = imagecolorallocate($im, 255, 255, 255);
// Draw a white rectangle
imagefilledrectangle($im, 4, 4, 50, 25, $white);
// Save the image
imagepng($im, './imagefilledrectangle.png');
imagedestroy($im);
?>
我試圖做到這一點與PHP和插入作爲圖像,但它不會顯示在我的電子郵件客戶端。 –
你在服務器上或本地嘗試過嗎?您需要像XAMPP這樣的Web服務器才能在本地運行PHP。 –
我在我的服務器上運行它。我做了2次嘗試,我剛打開文件,另一次嘗試在哪裏發送電子郵件。當我打開文件時,php工作正常。只有當我試圖發送電子郵件是我遇到問題的時候。 –