2012-01-03 3 views
0

PHP 응용 프로그램에서 보내는 전자 메일에 문제가 있습니다.전자 메일 내용이 표시되지 않습니다

이메일이 비어 있고 모두 특정 주소로 전송됩니다. 이 전자 메일은 내가 제어 할 수있는 주소로 CC'ed되어 있으며 모두 올바르게 수신됩니다. 모든 이메일은 HTML 형식으로 전송됩니다.

나는이 전자 메일이 전송되는 원격 전자 메일 주소를 제어 할 수 없지만 M $ 교환 스팸 필터를 통과한다고 100 % 확신합니다. 데이터가 누락되는 필터가 될 수 있습니까?

다른 의견이 있으면 좋을 것입니다.

답변

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

확인 답장을 보내 주셔서 감사합니다, 나는 이메일이 이미이 같은 전송하고, 텍스트 나 HTML 중 하나에서 확인 dislpay 것을 확인할 수 있습니다. 이것은 제가 시도한 첫 번째 것들 중 하나였습니다. – mic