While using App Engine’s Mail API, some applications may encounter the following error:
This error means that the application attempted to send email with a non-whitelisted from address.
To send email from App Engine, applications must declare a sending address matching one of the following: a registered administrator of the application, the Google user account of the currently-logged-in user, or an email address of the form:
[any string]@[Application ID].appspotmail.com
For most purposes, using the appspotmail string as a from address is perfectly fine. To generate this sending address, you can use App Engine’s environment variables to collect the application ID. For example, here’s how to do it in Java:
String application_id = SystemProperty.applicationId.get();
String sender = "donotreply@" + application_id + ".appspotmail.com";
For applications that need to send email originating from their custom domain, register a Google Apps account with the address you want to use, then register it as an administrator of the application.
Sender Policy Framework (SPF) is a way to validate outgoing mail; it essentially allows a domain to say, “only these named servers are allowed to send mail under my name; any other servers attempting to do so may be malicious or may be sending spam.” If you send mail from your domain, it’s important to set SPF rules so receiving domains know that your mail is valid and isn’t spam.
To create your SPF record, visit the SPF website and figure out the appropriate SPF record for your domain. Then place it as a TXT record in your domain’s DNS.
As an example, my domain sends no mail so the appropriate SPF record is:
If you have NameCheap as your domain registrar, here’s how to set an SPF record. First, log in and click the link All Host Records:
Put in the following settings:
Host Name: @
IP Address: v=spf1 -all
Record Type: TXT
Here’s how it looks like on the administration console:
If you use a different domain registrar there should be similar options. If not, contact your registrar for the appropriate steps to take.
Google’s Compute Engine just released into General Availability, and I’ve been testing it out the last couple of days.
The one thing that blows me away is how reliably fast even the low-end instances are. I provisioned and set up a f1-micro instance – it runs great and quite consistently. That’s in sharp contrast to Amazon’s micro instance which is limited to “bursty” processing; there are spikes where processing goes quickly, then the CPU gets throttled and the instance grinds to a near-halt.
I’m considering building a mail app on top of GCE – so far, everything looks great. GCE even allows inbound SMTP connections (although unfortunately no outbound SMTP connections).
I’m in the middle of writing a Java application on App Engine to receive mail, and I decided to look up on how to do it in Go. It’s shockingly easy, just a few lines of code (r represents http.Request):
c := appengine.NewContext(r)
msg, err := mail.ReadMessage(r.Body)
And that’s it. You can extract headers and the mail message body from the Message struct. It’s quite pleasant to use, and surprisingly fast at parsing email.