Best Way To Receive Email Website - linux

I am developing a website -- in the prototype stage, soon to be alpha. I will provide an email address to each account that allows the user to deposit stuff -- not a real email account, just an endpoint for sending things to the site. Many sites provide this kind of service nowadays. I think the first one I saw was Photobucket, which let's you send photos as email attachments.
My question is, what is the best way to implement this kind of service?
In my prototype, I have written a POP3 client which fetches all newly delivered mail (currently from a test Gmail account). My service processes each new mail and attachments, and immediately removes it from the email server.
I could certainly outsource to an email service with POP3 and be done with it. The problem is cost. Most services I have seen provide much more than I need, and they charge per account. I expect to have many accounts and low traffic volume.
So I'm leaning towards hosting email receipt myself. I am open to Windows or Linux. The code that processes incoming emails runs on Windows, but I have other services running on Linux. I have seen a number of open source and free email servers, such as hMailServer and MailEnable (Windows) and qmail, Postfix and exim (Linux).
I guess I have a slight preference towards Linux because of lower hosting costs, but if a Windows service can provide cleaner integration, that might be worth it. As far as features, I would like to have some spam filtering, but it's is not a huge priority. POP3 is adequate for retrieval, but a more direct API would be nice. I will need some kind of API for programmatically provisioning new accounts.
All suggestions are appreciated. Do you know how others implement this kind of service?
UPDATE: I ended up using hMailServer, which is a free mail server that runs on Windows. It seems to be quite mature and robust. It has a COM interop library which makes accessing emails, accounts, etc. from my .NET server app very easy indeed.

If you're going the host-your-own-email-server route, I would probably just use POSTFIX and pipe all your email to a PHP script, which processes the email.
Here's a quick'n dirty tutorial on setting up the email pipe if you're using cPanel:
http://kb.siteground.com/article/How_to_pipe_an_email_to_a_PHP_script.html
If not, here's how to do it:
http://answers.google.com/answers/threadview?id=562518

The bottom line is, you need to have an open SMTP connection to accept email. If you have your own server, then you can install a SMTP server on the machine. Usually, you have filesystem access to the location the email files are placed. Be sure to select a SMTP server that allows this, and that the email are in a format that you can parse.
Then, you can just monitor the file location for incoming emails.
If you can't pipe your emails (using the Postfix suggestion), and you don't have your own server (for example, on a shared hosting plan), then you will need to query a POP3 or IMAP mailbox server for your emails, and parse them accordingly.

I wanted to get emails in real time so I worked out my own solution with google app engine. I basically made a small dedicated google app engine app to receive and POST emails to my main site. That way I could avoid having to set up an email server.
You can check out Emailization (a little weekend project I did to do it for you), or you this small GAE app that should do the trick.
I kinda explained it more on another question.
Hope that helps!

Related

Setting up simple web application service and testing - Linux debian 10

I am doing my assignment given by the lecturer. On the title stated, my idea is about setting up a mail server on the server and we can send the email from the client, all the email is stored in the server virtual machine. Do my idea is correct on this title stated or any recommendations?
Sending mail is not that hard, especially just using (E)SMTP, tcp
text dialogs. Or you can use Linux mail commands.
Storing mail, either locally or accessing mail on a pop or imap server, poses
another set of challenges.
And of course, you need the HTML web pages as well as the services.
Attaching files can be another challenge, both uploading the files
and encoding them for inclusion in the mail.
JAVAScript can make some usual features of email clients easier, like sorting a list of emails in a folder or from a search by a column ascending or descending.
Searching email is an even bigger challenge!

trigger a .sh script when a specific subject email is received

Anyway, I have a script that I want to run whenever I receive an email on gmail. And if possible a subject specific email. is such a thing possible and if so, what programs do I need to allow it.
You can't instruct gmail to trigger an external script for you. I think you've got a few basic choices. In order of increasing difficulty and complexity:
1) Configure a gmail filter to deliver your desired messages to a special folder. Write a script to poll that folder, download (or delete or mark as read) messages it finds there, and then launch your local script. Set up a cron on your local machine to run the script every few minutes. You can poll the folder with IMAP or the GMAIL API. IMAP is probably easier. This will be tricky with shell, you're better of with Python, PHP, or similar.
2) Configure a gmail filter to forward your desired messages to an address on a mail server that you control. Use procmail or similar to intercept the incoming messages and launch your script.
3) Set up an account at Mailgun and configure the emails so they get delivered there directly. (Or forward from gmail as in #2.) Configure Mailgun to launch an API request when it receives messages. Build an API handler to receive the request. Launch your process from your API handler.
I have never done it, but I guess the first thing you should do is to take a look at the Google's Gmail API...
What is the Gmail API?
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History.
It seems to fit what you want - at least, without knowing the details of what you want to do.
The Gmail API can be used in a variety of different applications,
including, typically:
Read-only mail extraction, indexing, and backup
Label management
(add/remove labels)
Automated or programmatic message sending
You can use several programming languages - maybe the trick is using your programming language of choice to write a wrapper for the .sh script... I hope this helps!

Blacklisting on Google App Engine - users or devices (and not just IP addresses)

I have couple Android apps on PlayStore, which use In-App purchases. I use Google App Engine for my backend. I see some users calling the APIs abnormally/repeatedly (may be to reverse engineer or hack?). I can figure out the IP address, Gmail ID, etc. How to prevent these people from accessing my API?
One suggestion is to use dos.xml
But these morons seem to constantly change the IP addresses, so it is painful to keep updating this list.
Is there a way in App Engine to black list users? or computers/devices?
If we know the google(Gmail) Ids of these ba*t*r*s, how/where do we report those? This page seems to be the right place to start, but it is not clear where to send email.
This page seems be more appropriate for vulnerabilities, but this is not such a case.
"Viewing top users in the Administration Console" section in DoS page says I should see a table of IP addresses which are using the API frequently. But I dont see such table in Admin console. Do I need to be a paid (Google App Engine) user?
Any help is greatly appreciated.
Yes, GAE allows for a blacklist, via dos.xml (dos.yaml for Python or PHP). If you don't want to have to keep updating the IP addresses, you may just have to check the user id, and serve them some message. But, that requires actually servicing the request, to check the id, etc. So, if it is a true DOS attack, it will succeed, as you have to still service the request. Using dos.xml cuts that off at the backend, so would be the best way to go.
I suggest a script to log the IP addresses in real time for those you want to ban, to make updating dos.xml less painful.

After downloading a mail through IMAP, before parsing I want to check if its spam!

I have a ticket system in PHP. People report tickets over email. A mail parser connects to the mailbox using IMAP, downloads the email and parses it to create a ticket which can be viewed/updated over the web interface.
Now I want my application to check if the downloaded mail is a spam before it creates a ticket out of the mail. So I thought of integrating spamassassin. The docs say, it can be implemented as a proxy. I am not sure how to do this.
Basically what I want is a way to pass the email as a string to the spamassassin perl script which validates the mail?
Has anybody done something similar before. Can you suggest some other related good tools?
Edit: I am using Google apps mail-server. So its not an option to integrate SpamAssassin at the MTA or MDA stage.
Can you install spamassassin in your webserver? because spamassassin supports pipes. you can make a syscall from php to use spamassassin from command line and parse the answer. Or you can use this http://ppadron.blog.br/2010/05/04/php-api-to-spamassassin-spamd-protocol/ Or you can use a reliable antispam service for your domain.

Monotouch: any ideas why sending mail is sporadic?

This is the code: d59516457">http://monobin.com/_d59516457
These are the results when using Debug|iPhone (Debug|Simulator works fine):
When the "From" is set to GMail, I can only send to a GMail account.
When the "From" is set to my ISP, I can send to myself (at the ISP) and GMail, but NOT to another of my email addresses not connected to the ISP. (it's to an address for one of my websites, which is then forwarded to my ISP).
Any ideas why this is so flakey? I thought at first it was the ISP, but now I'm not so sure.. is there a way to "trace" any of hops?
I'm concerned that if I submit it to the app store, a user will have the same problem as this, and I don't want a bad rep for the app. On the other hand, because it works, sometime and not others, maybe I could hope it's my phone?
if you want you can use http://testflightapp.com/ so you get some beta testers doing Ad-Hoc releases of your app (you choose who you want to invite), if you want so I can send you an invite I would be more than glad to help you to test your app :) email me if you want the invite, my email its on my profile
About the solution, you can check if you have a webmail based interface that you can view on your computer, the email that you sent from the iPhone must be on the sent items folder, if the email and the attachment are there you can be sure that your application is delivering correctly you email to the SMTP server so the problem resides somewhere else...
Also make sure your that your smtp server is not blacklisted as a SPAM server even more if your smtp server relies on shared enviroment like Hostgator shared plans etc
Alex

Resources