sending email with GAE copies sender -- how to stop? - google-app-engine

I'm creating an app with GAE to allow people to vote in elections and this involves sending an email to each voter. I do this in a loop:
mail.send_mail(sender = manager.email(),
to = email,
subject = election.title,
body = body)
where manager is the signed-in user.
This appears to BCC the manager on all emails, but I don't want that to happen. Is there a way to send the email only to the intended recipient?

You can't - App Engine automatically BCCs the sender. If you don't want to receive them, you could use one of your app's incoming email addresses as the sender address.

There is an Issue logged for this problem here:
http://code.google.com/p/googleappengine/issues/detail?id=2059
Please "star" it if you want Google to fix it.

Related

How can I set default reply address in Gmail by API?

I'm trying to change "When replying to a message" (card "Accounts", section "Send mail as") to "Reply from the same address to which the message was sent" in Gmail Settings" by Gmail API (using service account that was delegated domain-wide authority) and I cannot find it in the docs (https://developers.google.com/gmail/api/v1/reference/users/settings/sendAs).
To explain why I want to do this: I'm adding certain role based Google Groups my users are member of to their send email as preferences (by the service account with domain wide authority). For example, users responsible for dealing with legal# address are member of Google Group called legal and they have legal mails in their mailbox. When responsible users change, I just change the membership and new users receive the mails. The problem is that just the first email comes to legal# and reply goes from john.smith# for example. Because of that, I decided to have them reply from legal#, so those who requests something from Legal Departament knows they are communicating with whole Legal Departament and not Mr Smith only. But when Gmail doesn't automatically choose correct address when replying to the legal mail, it doesn't do what I'm trying to do.
It doesn't matter for me if I change it in admin console or by script running on all users. I wasn't able to use any of those ways.
Thank you for your help,
Martin
I'm pretty certain that Gmail setting ("always reply from xx#yy, or reply from the same address to which the message is sent") is not available in the Gmail API. It really is a client-side issue, since the email client chooses the "From:" line when composing each message or reply.
For your issue, you should be able to use Google groups as a collaborative inbox, see: https://support.google.com/a/answer/167430?hl=en
This user note explains your use case, see: https://productforums.google.com/forum/#!topic/apps/siprUn9Nm9g

Sending email stopped working using anything#testapp.appspotmail.com?

I'm trying to send an email using the java api. I've got my app running live, no custom domain, in fact it's just a default project. Billing is not enabled. My app name is 'testapp'.
I'm using this email address for the sender:
admin#testapp.appspotmail.com
That seems to be ok if I'm reading the docs correctly (criteria #2):
For security purposes, the sender address of a message must be one of the following:
The Gmail or Google Apps Account of the user who is currently signed in
Any email address of the form anything#appname.appspotmail.com or anything#appalias.appspotmail.com
Any email address listed in the Cloud Platform Console under Email API Authorized Senders
The email was sent successfully twice, but now it has stopped working (same sender address, same recipient address). Nothing appears in the recipient's spam.
I can see in the quota page that the # of emails-sent keeps incrementing. But nothing is actually going through.
What am I missing?
Thanks
This is a known issue that is currently being tracked on the App Engine public issue tracker. Please feel free to star this issue for updates.

java googlemail blocks multiple access

I need to allow a user of my App to email themselves when an even occurs. I am not sure how to do this.
My first idea is to create a dummy gmail account, and have my App sign-in and send from there via java code. This means hardcoding the password BUT as account not used for anything other than one way emailing - it does not seem to be a problem.
However, I understand that google is pretty proactive about security and if my App (which is global) tries to log into same account in several different countries during a 24 hour period - it will block the email.
I have seen the "delegate" functionality, but that would mean that each user needs their own gmail account which is not practical.
Is there a way to force gmail to allow the sign-ins to happen from wherever?
Or is there a better approach to this problem?
probably not a good idea to have your app to mail from a private account, if I understand you correctly. Best to use email service like http://expresspigeon.com or http://sendgrid.com and simply send a transactional email from your app account. In other words, use an ESP.
The safest would be to ask the user for all the configuration information necessary to access their email server as themself, then send the email as themself to themself. You can use JavaMail to send the message, but you'll need to ask for all the configuration information that any other email application would ask for in order to configure access to their mail server.
There may also be Android-specific ways to do this using the default email application.

How do I send email from Google App Engine with a random sender?

How do I send email from Google App Engine with a random, non-app admin sender using a custom domain name (e.g. xyz#myshop.com ) ? We need to allow the users of our website to communicate with each other through a custom made messaging system but also allow them to reply directly from their email. Something similar with the craigslist system. However seems that GAE doesn't allow us to send email from an address that is not admin. Is there any workaround / patch ? We are the owner of myshop.com domain name (verified through google apps) so I don't see why a such thing is not allowed.
While you can't use just any random address, you can use a registered administrator address with a '+' suffix. So you could send the mail with a 'from' of, say, message-reply+HASH_VALUE#myshop.com. Then your app will receive the reply, and can use the hash to decide which user to forward the mail to.
How about sending the email from your admin account, but adding a reply-to header, specifying the user's email-address?
Google doesn't allow to use random addresses. You can star this bug.
http://code.google.com/p/googleappengine/issues/detail?id=3069
However, since the users are apparently registered with Google Apps, the system can send emails on their behalf when they are signed into your application.
The sender address must be one of the following types:
...
The address of the user for the current request signed in with a
Google Account. You can determine the current user's email address
with the Users API. The user's account must be a Gmail account, or be
on a domain managed by Google Apps.
http://code.google.com/appengine/docs/python/mail/emailmessagefields.html

App engine is not sending emails

my application deployed on app engine has been working succesfully half a year. One function is a sending of emails. But today it started to fail everytime with this error:
javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Illegal Arguments (java.lang.IllegalArgumentException: Unauthorized Sender: Unauthorized sender))
Of course sender email is registered in app engine console.
I didn't change anything!
Anyone who share same issue?
If someone have the same problem, the reason is the sender for the mail is incorrect or doesn't have permissions to send the email, I use the default noreply#your-application-id.appspot.com account to send the email.
InternetAddress from = new InternetAddress(
String.format("noreply#%s.appspotmail.com", SystemProperty.applicationId.get()),
"Your Application Name") ;
message.setFrom(from);
You can check if the account of your user is not marked as a spammer or disabled in Google Apps.
If you are sending a very large number of emails to a single email account, Google can throttle you. When we were sending emails whenever we got an error, we ran into a similar problem.
Also, there is a limit on number of calls to mail API per minute.
Maybe earlier you were sending mail to fewer people resulting in fewer calls to the mail api.
It's 8 calls per minute, unless you have provided a credit card number to enable your billing.
Does your sender email address has permission to access this app engine application ?
it's must have permission to access your application then it will work...

Resources