我从帖子中尝试了此代码,但此代码在一次文件运行中发送两封电子邮件。
让我知道我做错了什么 -
<?php
function mytextoverimage( $mytext ) {
$headurl = 'http://dummyimage.com/600x400/ffffee/00d5ff.jpg';
header('Content-type: image/jpeg');
$jpg_image = imagecreatefromjpeg($headurl);
$black = imagecolorallocate($jpg_image, 1, 1, 1);
$font_path = 'myfont/arial.ttf';
$text = $mytext;
imagettftext($jpg_image, 24, 0, 175, 85, $black, $font_path, $text);
imagejpeg($jpg_image);
imagedestroy($jpg_image);
}
$to = "myemail@gmail.com";
$subject = "This is a image conversion from Developer Zone";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: developer@phpdev.com' . "\r\n" .
'Reply-To: testabc@testabc.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = '<!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>My Title</title>
</head>
<body>
<table width="100%" cellspacing="5" cellpadding="0" border="0" bgcolor="#f0f0f0" style="color:666666;text-align:left; font:12px Verdana, Geneva, sans-serif">
<tr>
<td >'.mytextoverimage('Developer').'</td></tr></table></body></html>';
mail($to,$subject,$message,$headers); die;
让我知道我做错了什么,这是我使用的正确方法吗 -
<img src="'.mytextoverimage('Developer').'" />
我跟着这个 URL 但很难从这个页面破解任何帮助 - http://php.net/manual/en/function.imagejpeg.php
我什至尝试将该方法保存mytextoverimage()
在另一个文件中,但仍然没有帮助,电子邮件发送两次 :(