Ruby on rails 当我使用ActionMailer发送带有附件的邮件时,邮件正文缺失
视图中的内容未显示。仅发送附件。谢谢你的帮助Ruby on rails 当我使用ActionMailer发送带有附件的邮件时,邮件正文缺失,ruby-on-rails,ruby,actionmailer,Ruby On Rails,Ruby,Actionmailer,视图中的内容未显示。仅发送附件。谢谢你的帮助 def send @subject = "Status of PIS App" @recipients = "ssg@gmail.com" @from = APP_CONFIG[:email] @sent_on = Time.now #@content_type = "text/html" content_type = "multipart/alternative" attachment :filename => "Report
def send
@subject = "Status of PIS App"
@recipients = "ssg@gmail.com"
@from = APP_CONFIG[:email]
@sent_on = Time.now
#@content_type = "text/html"
content_type = "multipart/alternative"
attachment :filename => "Report.html",:content_type => "text/html",
:body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end
使用附件时,需要单独指定文本部分:
def send
@subject = "Status of PIS App"
@recipients = "ssg@gmail.com"
@from = APP_CONFIG[:email]
@sent_on = Time.now
#@content_type = "text/html"
content_type = "multipart/mixed"
part :content_type => "text/plain", :body => "contents of body"
attachment :filename => "Report.html",:content_type => "text/html", :body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end
您可能希望以多部分/混合的方式发送邮件,而不是以多部分/备选方式发送邮件(除非附件确实是文本部分的备选表示形式)