2014-01-06 2 views
-1

HTML 전자 메일 템플릿에 multipart/alternative (일반 텍스트) 지원을 포함하고자합니다. Google에서 구체적인 예를 검색했지만 찾지 못했습니다. 커스텀 뉴스 레터 모듈이있는 고전적인 ASP 웹 사이트입니다. 나는 현대 뉴스 레터 서비스가 이미 그러한 기능을 지원한다는 것을 알고 있습니다.전자 메일의 복수/대체 지원

내가 이것을 묻는 이유는 Google에서 검색 할 때 명확한 지침이 없기 때문입니다. 또한 많은 웹 사이트가 뉴스 레터 서비스를 언급하고 있습니다.

템플릿 :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    <meta http-equiv="Content-Style-Type" content="text/css"> 
    <title></title> 

<style type="text/css"> 
    /* setting font style for Outlook 2007 */ 
    body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,p,pre,blockquote,th,td,span,em { 
     color: #ffffff; 
     font-family: 'Trebuchet MS', sans-serif; 
     font-size: 15px; 
     line-height: 1.333em; 
    } 
    body { 
     margin: 0; 
     padding: 0; 
    } 
    p { 
     margin: 0 0 1.3em 0; 
    } 
</style> 
</head> 

<body style=" 
     margin: 0; 
     padding: 0; 
     color: #646567; 
     font-family: 'Trebuchet MS', sans-serif; 
     font-size: 15px; 
     line-height: 1.333em; 
     background: #281E14"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#281E14" style="background: #281E14"><tr><td valign="top" bgcolor="#281E14"> 
     <table width="680" border="0" cellspacing="0" cellpadding="0" id="DesignTester" align="center" bgcolor="#000000"> 
      <tr> 
       <td style="height: 28px;" height="28">&nbsp;</td> 
      </tr> 
      <tr> 
       <td> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
         <tr> 
          <td valign="bottom" style="padding-bottom: 20px; padding-left: 20px;"> 
           <h1 style="margin: 0; color: #FF0000; font-size: 30px; font-weight: bold;">##Titel##</h1> 
          </td> 
          <td align="right" valign="bottom" style="padding-bottom: 15px; padding-right: 20px;"> 
           <img src="http://##URL##/BeheerSjablonen/nieuwsbrief/images/logo.gif" alt="" width="129" height="70"> 
          </td> 
         </tr> 
         <tr> 
          <td valign="bottom" style="padding-bottom: 20px; padding-left: 20px;"> 
           &nbsp; 
          </td> 
          <td align="right" valign="bottom" style="padding-bottom: 15px; padding-right: 20px;"> 

          </td> 
         </tr> 
         <tr> 
          <td colspan="2"> 
           <img src="http://##URL##/BeheerSjablonen/nieuwsbrief/images/divider.gif" alt="" width="680" height="2"> 
          </td> 
         </tr> 
        </table> 
       </td> 
      </tr> 
      <tr> 
       <td style="padding: 24px 0"> 
        ##Intro## 
        ##Inhoud## 
       </td> 
      </tr> 
      <tr> 
       <td style="padding: 24px 0"> 
        ##Films## 
       </td> 
      </tr> 
     </table> 
    </td></tr></table> 
</body> 
</html> 

감사합니다!

+0

이런 질문을하기 전에 더 많은 연구를 수행하고 코드에 뭔가를 만드십시오 잘못 뭐가 있는지보고 검토합니다. 그래서 이미 작성한 코드에 도움이됩니다. –

답변

0

여러 부분 이메일 : (source) :

$notice_text = "This is a multi-part message in MIME format."; 
$plain_text = "This is a plain text email.\r\nIt is very cool."; 
$html_text = "<html><body>This is an <b style='color:purple'>HTML</b>" . 
      "text email.\r\nIt is very cool.</body></html>"; 

$semi_rand = md5(time()); 
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand"; 
$mime_boundary_header = chr(34) . $mime_boundary . chr(34); 

$to = "Me <[email protected]>"; 
$bcc = "You <[email protected]>, Them <[email protected]>"; 
$from = "Me.com <[email protected]>"; 
$subject = "My Email"; 

$body = "$notice_text 

--$mime_boundary 
Content-Type: text/plain; charset=us-ascii 
Content-Transfer-Encoding: 7bit 

$plain_text 

--$mime_boundary 
Content-Type: text/html; charset=us-ascii 
Content-Transfer-Encoding: 7bit 

$html_text 

--$mime_boundary--"; 

if (@mail($to, $subject, $body, 
    "From: " . $from . "\n" . 
    "bcc: " . $bcc . "\n" . 
    "MIME-Version: 1.0\n" . 
    "Content-Type: multipart/alternative;\n" . 
    "  boundary=" . $mime_boundary_header)) 
    echo "Email sent successfully."; 
else 
    echo "Email NOT sent successfully!";