메일보내기 img태그관련 채택완료
RinaP
8년 전
조회 2,266
메일보내기를 할때 메일보는 화면에 상, 하단에 이미지를 추가해서 보내게 했습니다.
근데 메일을 받아보니 <img src....로 적었던 부분들이 <ximg src...로 바껴있더라고요...
메일을 열어보는 사이트에서 바꾸는건지...안바뀌게 하려면 어떻게 해야하는지 궁금합니다
아래소스는 메일보내기 할때 내용추가하고 바꾸는 함수입니다.
</p>
<p>function send_mail_with_file($from_email,$from_name,$to_email,$subject,$body,$file){
if (strlen($to_email)==0) return 0;
$mailheaders .= "From: $from_name<$from_email> \r\n";
$mailheaders .= "Reply-To: $from_name<$from_email>\r\n";
$mailheaders .= "Return-Path: $from_name<$from_email>\r\n";
if ($file[size]>0) {
$boundary = uniqid("part");
if (strlen($file[type])==0) $file[type] = "application/octet-stream";</p>
<p> $mailheaders .= "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-Type: Multipart/mixed; boundary = \"".$boundary."\"";</p>
<p> $bodytext = "This is a multi-part message in MIME format.\r\n\r\n";
$bodytext .= "--".$boundary."\r\n";
$bodytext .= "Content-Type: text/html; charset=\"ks_c_5601-1987\"\r\n";
$bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";
$bodytext .= chunk_split(base64_encode($body))."\r\n\r\n";</p>
<p>
$bodytext .= "--".$boundary."\r\n";
$bodytext .= "Content-Type: ".$file[type]."; name=\"".$file[name]."\"\r\n";
$bodytext .= "Content-Transfer-Encoding: base64\r\n";
$bodytext .= "Content-Disposition: attachment; filename=\"".$file[name]."\"\r\n\r\n";
$fileSize = $file[size];
clearstatcache();
$files = fopen($file[tmp_name], "r");
$cont = fread($files, $fileSize);
fclose($files);</p>
<p> $bodytext .= chunk_split(base64_encode($cont))."\r\n\r\n";</p>
<p> $bodytext .= "--".$boundary."--";
} else {
$mailheaders .= "Content-Type: text/html \r\n\r\n";
$bodytext = $body . "\r\n\r\n";
}
if (!mail($to_email,$subject,$bodytext,$mailheaders)) {return 0;}
return 1;
}</p>
<p>
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인