1

我正在从 ruby​​ 脚本发送邮件,如下所示 -

body = File.new "body.html","w"
body.puts "Result body"
cmd = "mutt -e \"set content_type=text/html\" -s \"Automation Result\" -a \"Result.xls\" -- xxx@yyy.com < body.html"
system(cmd)

它正在发送带有附件但正文为空白的邮件。

奇怪的是当我这样做的时候

mutt -e "set content_type=text/html" -s "自动化结果" -a "Result.xls" -- xxx@yyy.com < body.html

它发送带有附件和 html 正文的电子邮件。知道出了什么问题以及如何解决吗?

甚至

mail = Mail.new do
  from     'automation_root@bidstalk.com'
  to       'maitreya@bidstalk.com'
  subject  'Hello'
  body     File.read('body.html')
  add_file :filename => 'Result.xls', :content => File.read('Result.xls')
  charset = "UTF-8"
end

正在发送没有正文的邮件。

4

1 回答 1

0

The mistake I was doing was I was opening the file, writing to it but not closing it before sending the mail so it was basically not saved and was 'null' when I was sending the mail.

just added - body.close before the mutt statement and it worked fine.

于 2014-07-14T11:34:58.000 回答