ruby - How to setup send HTML emails with mail gem? -


i sending emails using mail gem. here's code:

require 'mail' require 'net/smtp'  mail.defaults  delivery_method :smtp, { :address              => "smtp.arrakis.es",                        :port                 => 587,                        :domain               => 'webmail.arrakis.com',                        :user_name            => 'myname@domain.com',                        :password             => 'pass',                        :authentication       => 'plain',                        :enable_starttls_auto => true  }  end  mail::contenttypefield.new("text/html") #this doesnt work  msgstr= file.read('text2.txt')  list.each |entity|     begin         mail.deliver                'myname@domain.com'                  "#{entity}"             subject 'a subject'             body   msgstr         end     rescue => e     end  end end 

i don't know how set content type can format email html example. though wish able define bold text email client does: bold text. know content-type need specify in order achieve , how implement mail?

just note, code above works fine sending plain text emails.

from documentation

writing , sending multipart/alternative (html , text) email

mail makes basic assumptions , makes doing common thing simple possible.... (asking lot mail library)

mail = mail.deliver        'nicolas@test.lindsaar.net.au'      'mikel lindsaar <mikel@test.lindsaar.net.au>'   subject 'first multipart email sent mail'    text_part     body 'this plain text'   end    html_part     content_type 'text/html; charset=utf-8'     body '<h1>this html</h1>'   end end 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -