Sending Programmatic Email Messages - google-app-engine

I'm looking to send email messages programmatically from my websites. For example, if people register their email address, I would like to email them to confirm their email address. To do this I will need to use an email sending tool and plug into an smtp service. In the past (7 or so years ago) I used Jmail, however, I am not sure what are the best services to use today and how spam filters have envolved!
I have three specific questions:
Does it matter which service I use to send emails programmatically (e.g., PhpMail, Jmail, etc.)? If so, which tools would you recommend?
How should I host this tool? I plan on sending a large volume of emails (thousands to hundreds of thousands). Would it make sense to use google-app-engine mail service to do this, or should I just host it on my own server (e.g., have my own SMTP server)?
I don't want my emails to be sent to spam folders, how can I ensure that the emails are received by the users?
Thanks!

No, you don't need your own. Based on the tags of your message, I'm going to assume you are using java and deploying your app on Google App Engine?
http://code.google.com/appengine/docs/java/mail/

Related

how to send email on Code Name One using Gmail Api

I want to know if There Is a solution to send an email on a Code Name One app using Gmail Api,
i have an exception When i m using javaxmail,
error: cannot find symbol
import java.util.Properties;
symbol: class Properties
thanks in Advance.
You can use Display.sendMessage to send an email in Codename One. However, this is an "interactive" API that will launch the users email client and he'll need to press send to perform the actual emailing.
Alternatively you can use the sendgrid cn1lib to send an email via sendgrid. I would recommend against that though. If you send an email from the device that means your credentials (password etc.) would be on the device. A better way would be to contact your backend server and ask it to send the email for you. That way a hacker can't decompile your app and find out your credentials.
I agree with Shai's response, I'd just like to add a few more thoughts.
Sending emails from a mobile application (regardless of whether it is developed with Codename One) has two major problems:
the first problem, as mentioned by Shai, concerns the credentials: putting your Gmail account inside the client app code is a very bad idea;
the second problem is specifically about Gmail, since you're not referring to a generic mail service, but to Gmail itself: Stack Overflow is not the place to make recommendations on which services to use, however I can tell you why Gmail is probably not what you want to use. The main problem is that Gmail, when used for "third-party apps" (which Gmail considers insecure), doesn't allow you to change IP addresses frequently: if it notices an IP change, it blocks the service and forces you to manually unblock it in the security settings. Obviously the problem is minor if Gmail is contacted by your server that has a static IP address, but it becomes a big problem if Gmail is contacted directly from your users' phones, each of which will have a different IP.
That said, if your app made with Codename One needs to send emails (e.g. to activate new users), I recommend:
your app can use Codename One's Rest class to make a REST call to your RESTful server backend;
in your server, you could use an alternative service to Gmail that doesn't give problems if you change the server IP address every now and then or if you use the server both locally and remotely. For what is my experience, I can tell you that on my Spring Boot server I use org.springframework.mail.javamail.JavaMailSender, which is compatible with various mail services (just for information, I use a free ZohoMail account, however there may be many other alternative and equally valid mail services that I do not know).
As for using Codename One's Rest class, I'll point you to the developer guide (https://www.codenameone.com/developer-guide.html#_rest_api) and to this blog posts: https://www.codenameone.com/blog/terse-rest-api.html and https://www.codenameone.com/blog/new-rest-calls.html
When making Rest calls with Codename One, always keep in mind that there may be no Internet connection or other connectivity issues (or server-side errors), so careful handling of possible errors is critical.

Use Google's App Engine framework to read a mail and extract its attachments?

I'm developing a tool that lets an user receive some data through an email account, in the form of a regular file. The goal is to implement this:
file → email attachment → canbeanything#myapp.com → system backend copies attachment.
Can I use Google's App Engine to develop this application? I have read their documentation on handling email but I think it's bound to just the admin's account. Can you explain me the process for achieving this?
App Engine application can receive emails to a specific list of address. If my-app-id is your application then any email ending with #my-app-id.appspotmail.com will be sent to your application.
For example the following emails are valid destinations that will be received by your app :
hello#my-app-id.appspotmail.com
no-reply#my-app-id.appspotmail.com
...
Note that even if you app has a custom domain like myapp.com, the destination email address will remain in #my-app-id.appspotmail.com. You can probably circumvent this by configuring your domain's email settings to forward all emails to App Engine.
Once received by the App Engine infrastructure, the emails are POSTed to a specific URL of your app, where you can write a handler (a Servlet in Java) to process the email content and save it somewhere. Here is the Python documentation on receiving email, and the Java documentation.
Note that there probably is a limit to the size of attachments you can receive this way. I expect something along the line of 25Mo, which is GMail's attachment limit or 32Mo which is App Engine's POST request size limit.
Once you receive an email, I strongly recommend you perform the processing in a task queue, to avoid temporary issues (out of memory, faulty process) that would lead to the email being lost.
When it comes to saving the attachment, consider using Google Cloud Storage, since the Datastore is limited to 1Mb per entity.

send email on Google App Engine from custom domain

What I have done:
I have added my domain app.mydomain.com to my app engine project, and can successfully visit id.appspot.com using app.mydomain.com.
I have registered mydomain.com on google app for business.
The problem:
The problem is -- I am NOT able to send emails using #mydomain.com address. If I register an info#mydomain.com as an developer, this will probably solve the problem, but we need to send from more than one address, and I don't think registering a new developer for each address is reasonable.
Anybody knows how to solve this? Thanks!
You have two options:
Register all emails that you want to use as administrators/developers but as you mentioned in your post you don't want to do that.
Use SendGrid (or any other email services like Mandrill, Mailgun, etc.) which will give you a lot more features comparing to what GAE offers, including 25k free emails instead of GAE's 100.
According to the docs, the sender would need to be an administrator on the project (called "owner" in the new Developers Console). Another route would be to just use a separate email sending service like SendGrid or Postmark.
You can use the GMail API to send emails as users of your domain. Note that the emails need to be aliases, groups or users of your domain.
You shouldn't have any problem adding and verifying your domain, adding the necessary permissions to send emails. Then, every email address in your domain can be used. See here in the docs: https://developers.google.com/appengine/docs/java/mail/#Java_Sending_mail

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 free SMS apps like Pinger work?

I want to build an app whose core functionality is essentially the same as Pinger and other free SMS apps - that is, it needs to allow for texting without going through your phone's service provider by sending the data over the web. But I can't find any APIs or explanations as to how this is accomplished.
Pinger assigns you a phone number to use, which I assume means it must also run its own SMS gateways. But I don't know how to do either of these things (assign valid phone number and create SMS gateways), or whether I can even do them on my own and purely programatically. Does anybody know where I can find this information?
TL;DR: Essentially, I need to know how to create my own Pinger/free SMS app. My app will be different, but will employ the same underlying functionality.
SMS messages are not free to send and this is why Pinger's business model is based on advertising when you send and receive their messages, see http://www.pinger.com/content/advertise.html
In order to do this yourself you would need to work with one of the companies that offers a SMS gateway. You could use a whole bunch of different providers, take a look at this post I previously made with some of them How to send SMS programatically in a professional and reliable way?
I also add, you would need to work out a suitable business model to pay for the SMS messages you plan to send :-).

Resources