2012-01-03 185 views
0

我的PHP應用程序發送的郵件有問題。沒有顯示電子郵件內容

電子郵件收到空白,他們都被髮送到一個特定的地址。這些電子郵件也被抄送到我可以控制的地址,並且他們都被正確接收。所有的電子郵件都以HTML格式發送。

我無法控制這些電子郵件發送到的遠程電子郵件地址,但我100%確定他們會通過某種M $交換垃圾郵件過濾器。它可能是導致數據丟失的過濾器嗎?

對此的任何其他想法將是偉大的!

回答

2

你說所有的電子郵件都是用HTML發送的。您可能需要發送純文本才能使用它 - 以滿足那些不支持HTML的電子郵件客戶端。 http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

這是從上面的鏈接複製粘貼:

<?php 
//define the receiver of the email 
$to = '[email protected]'; 
//define the subject of the email 
$subject = 'Test HTML email'; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash 
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \r\n 
$headers = "From: [email protected]\r\nReply-To: [email protected]"; 
//add boundary string and mime type specification 
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 
//define the body of the message. 
ob_start(); //Turn on output buffering 
?> 
--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/plain; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit 

Hello World!!! 
This is simple text email message. 

--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/html; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit 

<h2>Hello World!</h2> 
<p>This is something with <b>HTML</b> formatting.</p> 

--PHP-alt-<?php echo $random_hash; ?>-- 
<? 
//copy current buffer contents into $message variable and delete current output buffer 
$message = ob_get_clean(); 
//send the email 
$mail_sent = @mail($to, $subject, $message, $headers); 
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed"; 
?> 
+0

好,謝謝您的回覆,我可以確認的電子郵件已經發出這樣的,並會dislpay在任何一個文本或HTML確定。這是我嘗試的第一件事情之一:s – mic 2012-01-03 10:05:28

相關問題