PHP로 메일을 보내면 Gmail에는 올바르게 표시되지만 Outlook에는 표시되지 않습니다. PDF 첨부 파일과 일부 텍스트가 포함 된 메일입니다. PDF는 fpdf로 만들어 첨부 파일로 보내지 만 Gmail과 Outlook에서 제대로 작동합니다.PHP 메일이 Gmail에서는 열리지 만 Outlook에서는 열리지 않습니다.
유일한 문제는 Gmail에서 이메일의 텍스트가 올바르게 표시되고 Outlook에서는 빈 페이지이며 텍스트가 추가 첨부 파일이라는 것입니다.
// encode data
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
// email stuff (change data below)
$to = $contactEmail;
$from = $myEmail;
$subject = "MySubjectHere";
$message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head></head><body>
<p>Hi '$contactName.',</p><br>
<p>Please find your pdf attached per your request.</p>
<p>Feel free to call or email if you have any questions.</p>
<p>Kind regards,</p><br>
<p>MyNameHere</p>
<p><strong>Manager</strong></p>
<img alt="image" src="http://LinkToImage.png"/>
<p style="color:#76923c;">
<strong>P:</strong> 01 2345 6789|
<strong>W:</strong> <a href="http://www.example.com" target="_blank">www.example.com</a></p>
<p style="color:#76923c;">
<strong>A:</strong> 94 Test Street.
</p></body></html>';
// a random hash will be necessary to send mixed content
$separator = md5(time());
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
// attachment name
$filename = $id."_".str_replace(" ","_",$Name).'.pdf';
// main header
$headers = "From: ".$from.$eol;
$headers .= "Bcc: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
// no more headers after this, we start the body! //
$body = "--".$separator.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol;
// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";
// send message
mail($to, $subject, $body, $headers);
질문이 있습니다. php를 사용하여 Outlook으로 전자 메일을 보내고받을 수 있습니까? 고맙습니다. – User014019
예. 헤더가 맞는지 확인하고 메시지 끝에 2 줄의 끝이 있어야합니다. 구조가 정확하다면 모든 클라이언트의 메일을 볼 수 있습니다. –
어떻게? 나는 전망에 이메일을 보내려고하지만 아무 것도받지 못했다. SMTP 서버와 포트를 넣어야합니까? – User014019