J'essaye d'envoyer un modèle d'email avec une image de php générée. Je suis capable de générer l'image quand j'ouvre le fichier sur mon serveur mais je ne suis pas capable de générer l'image quand j'envoie un email.Php ne fonctionne pas pour le modèle d'email
<?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....!";
?>
Le fichier php référencé est
<?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);
?>
J'ai essayé de le faire avec php et de l'insérer en tant qu'image mais il n'apparaîtrait pas sur mon client de messagerie. –
L'avez-vous essayé sur votre serveur ou localement? Vous avez besoin d'un serveur web comme XAMPP pour exécuter PHP localement. –
Je l'ai couru sur mon serveur. J'ai fait 2 essais où j'ai juste ouvert le dossier et un autre essai où j'ai envoyé un email. Quand j'ai ouvert le fichier, le php a bien fonctionné. Ce n'est que lorsque j'ai essayé d'envoyer le courrier électronique que j'ai eu les problèmes. –