Question

So, im building this webservice on Googles app engine, and i would like it to receive emails.

The thing is, i need to authorize the incoming mails and determine a destination based on alone on the TO field. This is to let people integrate the service in whatever email sending systems they already have running.

At least i need to variables, a key and a destination (which is also an email address):

An example could be:

af922514-60bc-4595-956d-ec29e6351d8e,kristian@mide.dk@application.appspotmail.com

Thats not really going to work (i think), is there any way to escape the first @, or should i go a completely other way around this?

I've thought about base encoding it so:

af922514-60bc-4595-956d-ec29e6351d8e,kristian@mide.dk@application.appspotmail.com

besomes this:

YWY5MjI1MTQtNjBiYy00NTk1LTk1NmQtZWMyOWU2MzUxZDhlLGtyaXN0aWFuQG1pZGUuZGs=@application.appspotmail.com

I'm not sure the ending '=' is allowed in email addresses though

Any thoughts on this?

Was it helpful?

Solution

First of all a comma would be no-go, since it would suggest multiple recipients, most mail clients will see the comma as a separator.

What you could do is format it like this:

some-var+recipient-addresse+domain.tld@someapp.appspotmail.com

When your app receives the email, you simply do a regexp that matches everything until the first + sign. There you have your variable, then match the rest until a @ sign, replace the last + with a @ and you have the email.

This would also allow the recipient email to contain + since you're only replacing the first and last + sign.

OTHER TIPS

Since + doesn't belong in a hostname, you could replace the last + with @ so that:

some-id,myinbox+tag+gmail.com@someapp.appspotmail.com

translates to:

myinbox+tag@gmail.com with some-id

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top