Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 当我使用ActionMailer发送带有附件的邮件时,邮件正文缺失_Ruby On Rails_Ruby_Actionmailer - Fatal编程技术网

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
您可能希望以多部分/混合的方式发送邮件,而不是以多部分/备选方式发送邮件(除非附件确实是文本部分的备选表示形式)