I've found this gem to be a great and easy way to send mail but I can't seem to send any html in it. If I write the following:
Pony.mail(
:to => message[:to],
:from => @account[:from],
:subject => message[:subject],
:content_type => 'text/html',
:html_body => "<h1>hey there!</h1>",
开发者_StackOverflow :via => :smtp,
:smtp => {
:host => MY_HOST,
:port => PORT,
:auth => AUTH,
:user => MY_USER,
:password => MY_PASSWORD,
:tls => true } )
The code above send a mail but the message appears to be empty in gmail.
Any help would be greatly appreciated on this.
Thanks.
You need to specify content type as a key inside a headers key. And then you can just put your HTML in a body, not an html_body.
Example:
Pony.mail(
:to => message[:to],
:from => @account[:from],
:subject => message[:subject],
:headers => { 'Content-Type' => 'text/html' },
:body => "<h1>hey there!</h1>",
:via => :smtp,
:smtp => {
:host => MY_HOST,
:port => PORT,
:auth => AUTH,
:user => MY_USER,
:password => MY_PASSWORD,
:tls => true } )
精彩评论