I'm wondering how I could map an email adress so newsletter users could simply write to a uniquely create email address and instantly get unsubscribed.
ex:
jonh.unsubscribe.sdfg87s544fsdg6#exemple.com
And the key here is that I want it to be instantaneous, I don't want to poll a imap or pop3 account every X seconds. Is there a way to listen to the inbox? Thats my main problem... once I get the email I know what to do.
Thecnologies I use:
Postfix
Python
PHP
If your mail server supports it, what you are looking for is IMAP IDLE (https://www.rfc-editor.org/rfc/rfc2177)
Otherwise, you would have to poll.
Mailman does this by redirecting the mail to the program itself (it never goes to a true mailbox). Since you're using Python on your project, it might be helpful to look at how mailman interacts with mail servers.
Related
Was hoping for some ideas as to a service to which I can set up an inbound-only email system. In other words, I will have multiple users on the system, each can receive their own email... but at the moment... at this time, I am not focused on the ability to send or reply to messages, only receive them and send to the appropriate user. I looked into Postmark... They seem to have some great functionality.
CloudMailin Is another alternative. However there are effectively three options for setting up something like this.
Use an existing, traditional, email server and poll for the emails
Setup your own email server and create a script to run when you receive an email
Use a third party solution, as you've already mentioned.
I went through for of these for Rails a little while back here, but all the information is still relevant.
On our website we use a MySQL table which contains all users. Some of the users should be able to send mails to all users. Unfortunately I haven't got the right idea how to implement such a system.
My current design:
A privileged user writes a mail to users#website.com using his personal mail software.
A server is waiting for incoming mails.
As soon as it receives a mail, it matches the 'From' field with the database.
If the user is not found or hasn't got the special flag, discard the mail.
Forward the mail to all users (mail addresses are saved in the database)
Send the sender a confirmation mail.
How can I implement such a system? I'm not required to stick to a certain programming language even though C++, PHP or Node.JS would be preferred.
As a jumping off point, look into IMAP/SMTP. You can, with any language, log into an email inbox, get emails, read them, etc etc etc. Set up your mailbox with an account users#website.com that receives legitimate emails. Then set up a cron job that checks the inbox every 5 minutes or so. If no emails are found, then you are done. If there is an email there, process it, run your checks against your DB, and then send it using SMTP, and then send the confirmation to the user.
If handling IMAP is too hard, you may just want to make a form on your website that privileged users can use which sends the emails to the users.
Given there is a "FAILTO=''" option for cfmail, triggering an email to be sent to that email if the email didn't get delivered...
Is there a way to somehow assign an ID or tracking # to an email, store it in a database with that ID... then update the status of that email if it fails?
I'd like to track bouncebacks... preferably WITHOUT sending the FAILTO to a POP3 or IMAP and then checking it with cfimap...
Is there any alternate way of handling this?
Maybe an event gateway that is triggered upon email failure?
UPDATE: I've decided to take a different approach, utilizing the sendgrid API.
I'm hoping that lends me with a few more tools than CF offers.
The short answer to your question is unfortunately no.
A longer version with a possible solution:
The failTo email address populates the return-path in the email header, this then 'should' be used by mail servers for bounce backs (however see - http://www.bennadel.com/blog/1899-GMail-Seems-To-Ignore-The-Return-Path-Header-Defined-By-The-CFMail-FailTo-Attribute.htm for an example where it doesn't)
So you are going to need to monitor an Imap or pop account to see your mails, however you can set up an event gateway to monitor this, with detailed instructions here - http://www.alagad.com/documentation/imapGateway/ImapWatcher%20Gateway%20Documentation.pdf
What you're left with is needing to identify which mail matches which bounceback, when I've done something similar in the past I used unique id's for the failTo email addresses at a domain I owned. If you set that up and then use your listener cfc to look for the id in the return-path.
So your sending code would work along the lines of:
Generate unique id
Send mail
Add row to database with unique id
Your listener.cfc would then need to inspect the email returned and if it finds the unique id update the row with whatever information that you're after.
Hope that that at least helps even if you'll need to set up some other bits.
You could use a directly watcher on the undelivr folder to log the failed emails, only really a solution if its own server and not a shared server though.
As far as I know once it leave the spool and is off to your SMTP server CF assume it's been sent correctly.
The email will trickle down the chain of SMTP servers/relays and if anything happen the only instruction they have is to bounce it back to the from address or failto address if present. CF isn't listening at this point so it can't respond.
We use an external tool called Glock email processor to handle exceptions. It's not free, but works pretty well. You can find it here: http://www.glocksoft.com/email-processor/
You need to configure it to check the failto address and from there you can take many actions. I got it setup as a three strikes system.
Email address bounce, I increment a counter in my email table, at 3 I deactivate that email from the system.
Nothing you can't do yourself with cfpop though.
My application server needs to notify users about some events via email. Usually there will be between 10-100 users to whom the notifications should be sent, but there may be a few cases where there may be a bit more (I don't think it will ever be more than 1000).
What is the best practice in such cases? Should I send a single email per user or one email with all users as recipients or group users and send one email for each group (for example 1 email for 10 users)? If it makes any difference I may add that I am using System.Net.Mail to send emails.
Thanks in advance for your suggestions
Lukasz Glaz
You should send one e-mail per user.
The alternatives either involve putting e-mails in BCC (which will increase your chances of having your mails flagged as spam), or revealing your user A's e-mail address to user B, where user A and user B are in the same "group".
You need to check with your smtp server manager - to avoid being blocked.
if you own the smtp server, than this is not a problem.
I think the best way is to send them in bulks of 50 recipients per message (it will be a little faster than one by one).
I wouldn't definetly put all recipients into a To: field. Even from one place. It's just not a good practice to show other's addresses. And it generates a problem when someone hits "Reply All" and suddenly mails all others with his crap :)
If you own the smtp server, and your application server -> smtp server connection isn't slow, I would just send every mail individually, with each single recipient in To: field. It just looks much less spam'ish then getting a mail with empty (or some bogus) To: field and being in BCC only.
Other advantage is the person recieving your mail will know what email address is used. I got plenty of them, use different ones in different places, and it helps to be able to see which one I used on which site (sometimes I need to use this address for password reset / login, and I forgot, and if all mails had me in BCC, I'm screwed). This is from your user's perspective.
I'm trying to write something that puts the contents of the message on a queue, to have work done on it later. I've been messing around with IMAP IDLE with varying degrees of success.
I was wondering if anyone knows of a method to have a mail server receive an email, and then perform an action like posting the contents of the email to a URL endpoint.
Any ideas? Thanks!
Try fetchmail and procmail. You periodically poll the mail server (every minute if necessary) and use fetchmail to download from the IMAP server. Set up a procmail rule to run your notifier application on emails that match your selection criteria.
Any of the scripting languages (perl, python, tcl/tk etc.) have good, mature and easy to use email handler libraries (in fact you can get this sort of thing for most lanaguages), so it should be quite straightforward to write the handler in one of those.
Configure the SMTP (mail transport) server to deliver the mail to an application that performs the desired action. Don't do it on the IMAP (mailbox client) level if you can avoid it.