3
새로운 사용자에게 html 환영 이메일을 보내고 있지만 작동하지 않습니다. 보낼 때, 실제 HTML을 렌더링하는 것과는 대조적으로 텍스트로 html 코드를 표시합니다. Mailchimp에서 템플릿으로 시작하는 템플릿의 html을 만들었으므로 작동하지 않습니다. 또한 Putsmail.com 및 emailonacid.com을 사용하여 전자 메일을 보내면 잘 보입니다.레일스 HTML 이메일 디스플레이
그러나, 생산, 이메일을 전송하고 HTML은 (registration_confirmation.html.erb에서)과 같이, 이메일에 텍스트로 나타납니다
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="width: 100% !important; -webkit-text-size-adjust: none !important; background-color: #ffa500 !important; margin: 0; padding: 0;" bgcolor="#ffa500">
<center>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="backgroundTable" style="height: 100% !important; width: 100% !important; margin: 0; padding: 0;">
<tr>
<td align="center" valign="top">
<!-- // Begin Template Preheader \\ -->
<table border="0" cellpadding="10" cellspacing="0" width="600" id="templatePreheader" style="background-color: #ffa500;" bgcolor="#ffa500">
<tr>
<td valign="top" class="preheaderContent">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td valign="top">
<div mc:edit="std_preheader_content" style="color: #505050; font-family: Arial; font-size: 10px; line-height: 100%; text-align: left;" align="left">
</div>
</td>
<td valign="top" width="180">
<div mc:edit="std_preheader_links" style="color: #505050; font-family: Arial; font-size: 10px; line-height: 100%; text-align: left;" align="left">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="600" id="templateContainer" style="background-color: #ffffff; border: 1px solid #dddddd;" bgcolor="#ffffff">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="10" cellspacing="0" width="600" id="templateBody">
<tr>
<td valign="top" class="bodyContent" style="background-color: #ffffff;" bgcolor="#ffffff">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td>
<a href="http://foobar.com">
<img src="https://s3.amazonaws.com/images/email_logo.gif" style="float:right;" alt="logo" />
</a>
</td>
</tr>
<tr>
<td valign="top">
<div mc:edit="std_content00" style="color: #505050; font-family: Arial; font-size: 14px; line-height: 150%; text-align: left;" align="left">
<span class="h2" style="color: #202020; display: block; font-family: Arial; font-size: 22px; font-weight: bold; line-height: 100%; margin-bottom: 10px; text-align: left;">Welcome to <%= user.name %>!</span>
Thanks for registering!<br /><br />
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="10" cellspacing="0" width="600" id="templateFooter" style="background-color: #FDFDFD; border-top-width: 0;" bgcolor="#FDFDFD">
<tr>
<td valign="top" class="footerContent"></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
</center>
<style type="text/css">
body { width: 100% !important; }
body { -webkit-text-size-adjust: none !important; }
body { margin: 0 !important; padding: 0 !important; }
img { border: none !important; font-size: 14px !important; font-weight: bold
!important; height: auto !important; line-height: 100% !important; outline: none
!important; text-decoration: none !important; text-transform: capitalize !important; }
#backgroundTable { height: 100% !important; margin: 0 !important; padding: 0
!important; width: 100% !important; }
body { background-color: #FAFAFA !important; }
.preheaderContent div a:visited { color: #336699 !important; font-weight: normal
!important; text-decoration: underline !important; }
.headerContent a:visited { color: #336699 !important; font-weight: normal
!important; text-decoration: underline !important; }
.bodyContent div a:visited { color: #336699 !important; font-weight: normal
!important; text-decoration: underline !important; }
.footerContent div a:visited { color: #336699 !important; font-weight: normal
!important; text-decoration: underline !important; }
body { background-color: #ffa500 !important; }
</style>
내 메일러 :
: 사용자 등록 모델에서 호출def registration_confirmation(user)
@user = user
subject "Welcome #{@user.first_name}!"
from "[email protected]"
recipients @user.email
sent_on Time.now
end
text/plain
에
def registration_confirmation(user)
@user = user
subject "Welcome #{@user.first_name}!"
from "[email protected]"
recipients @user.email
sent_on Time.now
# Set content-type header
content_type "text/html"
end
이 기본값을, 그래서 당신은 명시 적으로 HTML 또는 다중 메시지를 설정해야합니다 :3210
마이클! 텍스트와 HTML 버전을 갖도록 여러 부분으로 된 전자 메일을 만들고 싶다면 동일한 content_type을 사용할 수 있습니까? 알리미의 모든 전자 메일에 대해이 기능을 설정하고 싶습니다 (모두 여러 부분으로 구성되어 있습니다). – yellowreign
@yellowreign 다중 이메일에 대한 [ActionMailer] (http://rails.rubyonrails.org/classes/ActionMailer/Base.html) 문서 사례를 참조하십시오. 당신은 다른 내용 유형이 필요하고 각 mime 부분 (plain & html)에 대해'part'를 호출해야합니다. –
@MichaelBerkowski'mail (: body => @body, subject : @subject, : to => @recipients, : headers => @headers, : content_type => "text/html")'..하지만 여전히 텍스트를 보내고 있습니다. – abbood