I’m using Ruby to send email via Google apps. The email is being sent and received. The issue is that the email appears in my Gmail inbox as being sent to undisclosed recipients, and with no subject.
require 'rubygems'
require "tlsmail"
message = <<MESSAGE_END
From: From Address <from.address@googleappsdomain.com>
To: My Address <my.address@mydomain.com>
Subject: The Subject
Date: #{Time.now.rfc2822}
This is the email body.
MESSAGE_END
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start('smtp.gmail.com', 587, 'smtp.gmail.com', 'from.address@googleappsdomain.com', 'password', :login) do |smtp|
smtp.send_message(message, 'from.address@googleappsdomain.com', 'my.address@mydomain.com')
end
As I noted, the email is received. The headers look like:
from: From Address To: My Address Subject: The Subject Date: Tue, 28 Feb 2012 09:54:22 -0500 from.address@googleappsdomain.com
sender-time: Sent at 9:54 AM (GMT-08:00). Current time there: 7:45 AM. ✆
to:
date: Tue, Feb 28, 2012 at 9:54 AM
With the subject missing.
This is not a huge deal, but I’d like to get it coming in like a typical email if possible.
I don’t know if you are firm on using
tlsmail, but I have had success with Pony and Google Apps. Here is a modified example of mine:I wrapped this up in a helper (I’m using Sinatra) and pass in specific parameters, merging those with the default options (shown here). I’ll update if you’d like to see that as well.