![](/img/trans.png)
[英]Printing just the value of an array in email body with PHPMailer?
[英]image in email just printing url
我有一個簡單的PHP電子郵件腳本,希望在底部包含一個圖像。 當我在下面添加圖像標簽時,電子郵件僅顯示<img src="http://domain.com/images/logo.png" />
而不是實際圖像。 有什么想法嗎?
<?PHP
$email = $_POST["emailaddress"];
$to = "you@youremail.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$headers .= "Content-type: text/html\r\n";
$message = "A visitor to your site has sent the following email address to be added to your mailing list.\n
Email Address: $email";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: info@domain.com\n";
$usermessage =
"
Thank you for joining our mailing list.
We hope to see you very soon!
Address 1
Address 2
<img src=\"http://domain.com/images/logo.png\" />
";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
$fh = fopen("email.xml", "a");
fwrite($fh, "$email\r\n");
fclose($fh);
?>
您沒有通過正確的消息傳遞Content-Type標頭。 $headers
確實包含正確的標題,但是它與純文本消息一起發送,而$userheaders
不包含Content-Type
標題,但是與之關聯的消息確實包含一些HTML
更換
$userheaders = "From: info@domain.com\n";
同
$userheaders = "From: info@domain.com\r\n";
$userheaders = "Content-type: text/html\r\n";
它應該可以正常工作
這是一個按單詞的插件,但是如果刪除所有內容,但要刪除XmailBaby類,它將很好地為您服務。 該代碼是一件很好的工作,可以很好地發送電子郵件。 它只是一個基本版本,但對您來說應該足夠了。 看一下代碼,您可能會發現它很有趣。
http://plugins.svn.wordpress.org/xmail-the-right-way/trunk/xmail.php
您需要指定html標頭。 您可以使用一種完善的方法來支持發送HTML電子郵件,而不是自己這樣做,例如PHPMailer:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.