Note that there are some explanatory texts on larger screens.

plurals
  1. POSending email on behalf of Google Apps user
    text
    copied!<p>According to the documentation it is possible to send an email message using GAE on behalf of the currently logged in user, if that user has a Gmail or Google Apps account:</p> <blockquote> <p>For security purposes, the sender address of a message must be the email address of an administrator for the application or any valid email receiving address for the app (see Receiving Mail). The sender can also be the Google Account email address of the current user who is signed in, if the user's account is a Gmail account <strong>or is on a domain managed by Google Apps.</strong></p> </blockquote> <p>The following code works for sending emails on behalf of Gmail users but not Google Apps users. Attempting to send mail from a Google Apps user results in an 'Unauthorized sender' error.</p> <pre><code>current_user = users.get_current_user() message = mail.EmailMessage() message.sender = current_user.email() message.subject = 'subject text' message.to = 'joe@example.com' message.body = 'body text' if message.is_initialized(): try: message.send() except Exception, e: logging.error('Unable to send email update: %s' % e) else: logging.error('Email message improperly initialized') </code></pre> <p>What am I missing? Are there other dependencies that I should be aware of?</p> <p>EDIT:</p> <p>Full stacktrace:</p> <pre><code>Unauthorized sender Traceback (most recent call last): File "/base/data/home/apps/s~core-comps/1.358275951854397525/handler_cs_ticket.py", line 274, in sendEmailCopyToClient message.send() File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 900, in send raise ERROR_MAP[e.application_error](e.error_detail) InvalidSenderError: Unauthorized sender </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload