Google App Engine Emails Going to SPAM folder - google-app-engine

When I send emails through google app engine using the mail's send_mail function, they often get placed in the receiver's SPAM folder. Although this problem does not happen for GMail accounts, it does for Yahoo Mail accounts (and presumably several others)
Is there a way to get the emails GAE sends around the SPAM filter?

This is going to depend a great deal on what about the messages you're sending gets them marked as spam. Google's documentation suggests that it's the app engine that actually does the SMTP, so there might be some other google app engine app that someone's marked as spam and your sending IP (which happens to be the same) is getting tarred with the same brush, or it might be something about the content of your messages. Many big mail providers give you some way to determine how 'spammy' they'll think a particular message will be; perhaps you could get information that way?
Another option is the standard 'be careful to add [some address] to your safe senders list if you want to get email from us!' warning in your app.

See this reasoning, provided by Gmail on how it filters incoming email based on the header information. The key thing to note here is that all emails sent via GAE's SMTP infrastructure are sent via email IDs of the format xyz.apphosting.bounces.google.com, which by Gmail's definition itself brings the emails under the category of falsely / apparently bounced email messages, hence they get categorized as spam. The same would hold true for other email service providers that follow similar logic for spam filtering.
GAE still needs to come up with a good solution to this problem. In the meanwhile, the suggestion I would give you is to use an external email service. Since GAE does not allow you to open arbitrary TCP sockets, you can use the URLFetch service to submit requests to external services that can open SMTP connections and send email on behalf of your email ID.
While this approach shifts your email sending costs to the external service, it consumes additional GAE resources, namely- UrlFetch service API calls and UrlFetch Data sent.
Update: Google App Engine plans to launch support for outbound sockets soon as part of their production feature roadmap, so making external SMTP connections directly would become a possibility.

Related

GAE Mail Send Quota = 100/day?

I have my own domain with G-Suite Business and application in GAE that sending emails to our clients. But limit 100 sendings per day is too low.
How to increase mail send quota above 100/day? That's possible?
Thanks for any ideas.
The build in GAE mail is not really intended for production use, on top of the 100 mail limit there is also a limit on how many unique email addresses can be sent to in 1 day if im not mistaken.
For production I would recommend SendGrid, documentation can be found here : https://cloud.google.com/appengine/docs/standard/python/mail/sendgrid
Good service with a lot of needed mail features, like custom domain etc.
Google Cloud Platform support no longer provides quota increases for the Mail API.
Besides that, Richard's reply is correct so you can use Sendgrid or other available mail providers mentioned in the documentation. Additionally, as you mentioned GSuite, you may consider using Sockets API with your GSuite accounts (subject to GSuite quota).

Do outgoing emails using JavaMail through Gmail/Sendgrid SMTP count towards Mail API limits in Google App Engine?

I'm running an app on the Google App Engine standard environment. We need to send out a lot of emails and it looks like App Engine now lets us use JavaMail to send emails using SMTP - connecting to smtp.gmail.com or smtp.sendgrid.net.
I was wondering if this counts towards the Mail API limits/quotas in App Engine. I'm guessing it shouldn't, since the email is actually sent by the respective SMTP server and it's only outbound traffic from App Engine. Is this correct?
Note: I'm not a Java user, the answer is based on documentation only.
Indeed, using 3rd party partner mail services is the Google recommendation for sending lots of emails. From Quotas and limits:
Each Mail service request counts toward the Mail API Calls quota.
There are also quotas for the number of messages you can send, the
number of Admin messages you can send, and the amount of data and
attachments you can send. For more details, see Mail quotas.
[...]
If you need to send more mail then the quota allows, you can use a
third-party mail provider, such as SendGrid or Mailgun.
And JavaMail can, indeed, use these 3rd party SMTP servers. From Sending email messages:
To send email messages, use the JavaMail classes included with the App
Engine SDK.
When you create a JavaMail Session, if you do not provide any SMTP
server configuration, App Engine uses the Mail service for sending
messages. Alternatively, add SMTP configuration for supported
third-party mail providers such as Mailgun, Mailjet, or
SendGrid.
This last quote appears (depending on how you interpret it, I guess) to support your assumption that when SMTP servers are specified the Mail service would not be used, thus those calls wouldn't be counted against the Mail API Calls quota.
Also each of the 3rd-party mail integration documentation page referenced in these quotes doesn't (or at least doesn't directly) use JavaMail, instead they require specific libraries/modules. Which might have some relationship with bypassing the GAE Mail Api quota limits. For example, from Sending Email with SendGrid:
Sending an email
It's easy to get started with the Java library for SendGrid to
send emails from your App Engine apps.
With the prerequisites complete, make sure you are set up for
Java on your local machine. The last thing you'll need before
writing code is to copy Sendgrid.java to the src directory of
your app. You'll import this class so that you can create a SendGrid
instance and send mail with simple commands.
So, to gain certainty, my suggestion is to actually put your assumption to the test: send some emails using JavaMail while specifying your SMTP server info, then check your actual usage in the developer console Quotas page for matching increases. Notes:
give some ample room for propagation delays - the usage counts might not be immediately updated
if you don't see the Mail section in the Usage table check also, towards the bottom of the page, a Show resources not in use button/link (but, if it's in there, it means the usage is zero).
You could also directly follow the recommended specific instructions for your 3rd party provider of choice and practically avoid the question altogether :)

Google Cloud (Direct) Incoming SMTP

We have an AppEngine that receives automatic data via email from remote sites and stores it into the datastore. We're using a 3rd Party SMTP host now, and /_ah/mail/ is working properly.
A lot of this data is coming from legacy microcontrollers, PLCs, smart meters and the like. They all have a configuration for email address, SMTP server, SMTP user/pass, From address, and interval.
We'd like to setup postfix on a g1-small Compute Engine instance to handle authenticated direct-SMTP connections for the incoming data, but there are no examples of anyone else doing this. Is it as simple as writing a postfix filter to take the data and POST it over to /_ah/mail on AppEngine?
Alternately, is there an easier way that we're missing? We are converting some of the devices to use POST/PUT where possible, but we have a lot of different devices, and that will take time.
Google App Engine provides an SMTP service for inbound email - messages sent to <anything>#<app_id>.appspotmail.com will be sent to /_ah/mail/<anything>. If your devices only need to send email into your system you could point them directly to GAE's mail servers.
Your suggestion of running a inbound mailserver on GCE and using it to forward to HTTP on your app is also a viable solution, and doesn't require abusing email servers. There are even companies that will do this for you!

Send email from a Google Apps nickname on Google App Engine

I'm trying to set-up a business website using App Engine. Previously, I had prototyped the site using my personal gmail account, but now I've purchased a domain name and have set-up google apps. So far, the only hitch I've encountered is getting my contact form to properly email people who try to contact me. Originally, I was using this code:
from google.appengine.api import mail
sender_email = "Admin <admin#example.appspotmail.com>"
mail.send_mail(sender_email, contact_email, subject, body)
I'd like to change sender_email to guru#example.com where guru is a "nickname" for my email account on Google Apps.
When I try to add guru#example.com I can receive an invitation email but can't add the nickname as a separate account.
Is there any way to do this without adding a new mailbox to my Google Apps account?
You will need to add a new mailbox.
I spent some time researching this issue and found no work arounds. Outside of possibly using Python E-Mail library and my initial look into it seemed more effort than it was worth for my applications. You will also need to host an email server somewhere and configure your mail exchange records in DNS properly.
If you do write your own email sending function and you're changing the sender your message will likely be flagged as spam.
Also if you plan on processing or receiving mail using your App Engine app it will need to be addressed to user#myapp.appspotmail.com as well. Thus negating all that extra effort to keep from using appspotmail.com

Adding Instant Messaging (possibly XMPP) to my website on AppEngine (without using Google Login IDs)

I have developed a dating website built on top of the Google App Engine, to which I would like to add instant messaging, and possibly/probably audio and video conferencing.
Given that the users on the website do not want to share their personal details or real contact information, I am handling all of the login information and sessions without assuming that the clients have (or even want) a google account ID or any other login that is associated with their real identity.
I would like to hear suggestions on how I could go about adding instant messaging to my website given that I cannot just directly access Google Talk or some other existing service.
Would it make sense to use XMPP for this, and if so will Google Talk or any other XMPP service provider allow me to register new user accounts without manual intervention (ie. after a user is registered on my site, automatically register them with the XMPP provider)? Or, if not, perhaps I can use a single google ID with Google Talk with a different resource identifier for each user (me#google.com/user1, me#google.com/user2, etc...), and send messages between the different resources? Could this work, and/or would having thousands of simultaneous connections to a single account get me banned from Google Talk?
Perhaps some kind of AJAX based solution might make more sense given the fact that users are already registered on my website, but are not registered for an XMPP service?
Any suggestions about how I might approach this problem would be greatly appreciated.
Kind Regards
-Alexander
Text chat is the easier problem. You can do either with or without XMPP. Without XMPP, you'll be building a Facebook chat type client on your pages that sends messages from each user to the app, and the app then shows then on the recipient's screen.(The client can be polling, or use comet when it comes out). Check out olark to see how this works.
Once you build code to use the app as a switchboard that routes the correct message to the correct person (anonymously, maybe), you can port this easily to XMPP if you require. Both parties add you.dating.site#appspotchat.com to their buddy lists, and you send all messages from girl#site.com to guy#site.com and vice-versa. (assuming a heterogeneous site.)
Audio and video, I have no clue how to do without sharing details between the parties :-/

Resources