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>",
: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 } )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With