我正在尝试发送一个生成php图像的电子邮件模板。当我在服务器上打开文件时,我能够生成图像,但是当我发送电子邮件时,我无法生成图像。
<?php
//change this to your email.
$to = "Brian Chiem <brian.chiem@yahoo.com>";
$from = "Performance <do-not-reply@yahoo.com>";
$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]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@maaking.cXom[/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);
?>
答案 0 :(得分:0)
最佳解决方案是动态创建条形图,然后将其转换为图像。
答案 1 :(得分:0)
"<?php imagefilledrectangle.php>>
看起来像一个错字。没有关闭PHP或你的报价。尝试一次也需要。
"<?php require_once 'imagefilledrectangle.php' ?>"