我正在尝试使用rails应用程序中的邮件程序发送一封带有附件的html电子邮件。我可以发送文本附件,但当我尝试其他任何内容时,附件都是通过电子邮件发送的,但附件中什么也没有显示。我已经尝试了各种文件,包括pdf和png文件。我没有在程序或日志中得到任何错误。下面是我的代码:
来自我的邮件:
attachments['test']=File.read(Rails.root.join('app/assets/images','Hello.txt'))
attachments['mcp_logo.png']=File.read(Rails.root.join('app/assets/images','mcp_logo.png'))
mail(to: recipient, from: 'Email@email.com', subject: 'Test Moodifer Email') do |format|
format.html {render 'moodemail'}
format.text {render :text => @text}
end 在我的控制器中:
MoodMailer.moodemail(@text,@recipient,@name,@mood,@time,@type).deliver以下是尝试将png作为附件发送时日志显示的内容:
----=_mimepart_534ca2511ae1c_11c818d488c18274
Content-Type: image/png;
charset=UTF-8;
filename=mcp_logo.png
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=mcp_logo.png
Content-ID: <534ca251eac9_11c818d488c180ca@owner-PC.mail>
iVBORwo=发布于 2014-04-15 13:26:21
试着把所有的图片都放到public directory里。请确保您提供了正确的路径。
https://stackoverflow.com/questions/23074066
复制相似问题