I’m using ActionMailer to send an e-mail with attachement, but I
receive the same e-mail attachement corrupted.
How I can resolve that?
The enviroment is:
- Windows
- Microsoft Exchange Server.
Code Enviroment.rb:
- ActionMailer::Base.delivery_method = :smtp
- ActionMailer::Base.smtp_settings = {
- :address => ‘nome_do_servidor’,
- :port => 25,
- :domain => nil
- }
Code Method to send e-mail:
- def enviar(mensagem)
- @subject = mensagem.assunto
- @body = {:mensagem => mensagem}
- @recipients = mensagem.para
- @from = mensagem.de
- @sent_on = Time.now
- @headers = {}
- unless mensagem.arquivos.blank?
-
arquivo = mensagem.arquivos
-
attachment(:filename => File.basename(arquivo)) do |a|
-
file = File.open(arquivo, 'r+') {|f| a.body =
f.read}
13. end
14. end
15. end
Thanks,
Daskandonga