2

Google App Engine has a rule of only allowing app admins to send email. Is there a workaround that anyone out there is using to send emails from non-admin addresses?

I'm building a B2B white-label platform, and being able to mask the "FROM" address is very important without giving my customers admin access.

Alvin Tan
  • 119
  • 1
  • 6

3 Answers3

4

The docs also state:

Any valid email receiving address for the app (such as xxx@APP-ID.appspotmail.com).

So you can make up an sender address based on that, and even correctly route that email back into your app if anyone replies to it.

Chris Farmiloe
  • 13,935
  • 5
  • 48
  • 57
  • Hi Chris, that's pretty good, but it will not hide my app-id from the recipient; my app-id contains my app name (in fact, it is exactly my app name). Is there any other way, other than using an @appspotmail.com address or the current logged-in Google user? – Alvin Tan Aug 12 '11 at 03:31
  • @AlvinTan you may set-up a CNAME so you can have your own domain name seen in the "from" header such xxx@message.example.com. Also the response of my question may be helpful . See http://stackoverflow.com/questions/9489134/how-do-i-send-email-from-google-app-engine-with-a-random-sender – themihai Feb 29 '12 at 14:38
2

It is also possible to send email on behalf of a logged in user, assuming that user is using a Google Account.

user = users.get_current_user()
message = mail.EmailMessage(sender=user.email())    

#Set other message components, such as message.body

try:
  message.send()
except:
  message.sender = #An APP-ID.appspotmail.com address, or Admin address
  message.send()
Kevin P
  • 1,655
  • 10
  • 16
1

If you need the email to appear as if it was sent by a user and when replied to reply back to that user's actual email address then you can make use of reply_to.

user_name = 'Some Guy'
user_email = 'some.guy@whatever.com'
admin_email = 'no-reply@yourdomain.com'
from_email = '%s <%s>' % (user_name, admin_email)
reply_to = '%s <%s>' % (user_name, user_email)
mail.send_mail(from_email, to_email, subject, body, reply_to=reply_to)

This way to the person receiving the email it will appear that it came from user_name and if they reply then their reply email will be sent to user_email.

The main negative of this approach is that if someone looks closely at the address they received the message from they will see the admin email address but most email clients show the name more prominently.

On the plus side you can send as any email address and most people would never notice it came from an admin email address.

Bryce Cutt
  • 1,525
  • 10
  • 20