I want to process a particular mailbox when it receives mail, I know I could have cron check every n minutes for any mail, but wondering if there's a way to "listen" for mail rather than continually polling.
Try a .forward file
You can pipe the message into any program or script you want, but also check if procmail can do what you want.
Depending on your mail server, it may be possible to actually have any incoming message be delivered to a process. Either in a .forward or by setting up something more advanced. In exim you can setup a transport to run a command, for certain addresses.
If you're using postfix I'd suggest aliasing the mailbox you're interested in to a process that will do the work for you. Then there's no polling. The message comes in and goes directly to being processed.
As Jason and Zoredache have already mentioned, you might be able to do this in the MTA itself. Another possibility is to have inotify watch the mailbox file or maildir.
if you dont have a mail-server on your own (root-access) - you could use a web service for that: http://cloudmailin.net (200mails/month for free) - works like charme and helped me out.
Related
Receiving mails with node-read is basically no problem thanx to the mail node.
My current problem is that I do not know how to avoid receiving the same mail twice when the server is restarted. One solution would be to delete every mail received, it I can't find a node for doing so.
Another problem which could arise is derived from the documentation - only the last mail is received. If, in a given intervall, several mails arrive, I guess only one of them will enter the flow - is tehre any solution for that?
One workaround I currently use is to send another mail to the inbox after processing the first one. The second one is recognized as "status"-mail and will not be processed.
I am working on an application (in Delphi XE8) that amongst other things allows the user to send emails. The solution I have chosen is to simply save the email as a text file with a "From:" and "To:" field in a SMTP pickup directory, which has worked fine up to now. I use a SMTP virtual server set up in IIS 6.
However, a new requirement is to be able to choose the sending time of the email. Is there some way I can specify this through the text file, or is this only possibly by changing the IIS settings? I would be very grateful for any tips that anyone may have.
If your code can detect the From And To fields correctly, why not just add a Time: entry in your text file and skip that file if the time has not been reached?
Try using IMAP4 (standard protocol for service-based handling of mails and folders for a mail client) instead of SMTP. Then use an email client that supports postponing of sending messages, and use its scripting to configure message sending the way you want it.
If your program continues running till send time, you could also create a thread that waits till the time you want the message sent, but I suppose that is too simple :)
Is there any extendable mail server that can implement a service like a chat robot?
I think what I am looking for is a middleware based on SMTP.
Most unix MTAs can do that. One way is to make a login called foo so that you have an email address foo#example.org. Then you put |/home/foo/program into /home/foo/.forward. Now /home/foo/program will be invoked on each incoming mail, receiving the message content as input.
There's a program called formail which may be quite handy (if you write in sh).
I found this library and it provides exactly what I need.
https://code.google.com/p/subethasmtp/
In a couple of recent projects, I've written an e-mail queue as a database table that is checked every minute by a cronjob. The cron script waits a few seconds in between sends.
The reason I did this was because I read somewhere that it helps your e-mail not end up in the spam folder if it's not blasted out from the same server all at once. I don't remember where I read it.
What do you think? Should I just mail things immediately or is an e-mail queue a good idea?
What are some pros and cons to this approach?
EDIT: Added last paragraph.
Do you have control over your SMTP server? If so, then there's no point in doing an email queue PHP-side. The SMTP server will already have queueing capabilities. If you're worried about blasting a particular receiving server, you can always turn on your SMTP server's throttling (if it has it), something along these lines.
I want to send out one off emails from a linux server. The server does not need to receive emails back.
Is there a simpler solution than sendmail for sending outgoing emails only?
I would prefer to use Perl to send the email.
Calling out to /usr/lib/sendmail is usually the preferred method because it handles delivery problems correctly. This does not mean using sendmail. Most (all?) mail transport system provide a command that's just named sendmail and provides an interface compatible to the original.
Alternatively you can send directly through a SMTP relay using a package like Net::SMTP but be extra sure to correctly cater for delivery problems.
Sendmail is not the only choice. you can use Postfix, Qmail, and many others
my Perl scripts call the mailx command. to know how to use it, type 'man mailx'
However this require to have a MTA correclty configured.
Or you can just use the Net::SMTP perl library and use your smtp server of choice
I have used msmtp successfully, ie it supports great authentication
TJ Luoma did a nice writeup of it on TUAW
I find nullmailer a very useful solution for the described scenario. Nullmailer is a sendmail/qmail/etc replacement MTA which relays to a fixed set of mail servers. It is very simple to configure and consumes little resources.
One important advantage of nullmailer over other mentioned solutions like mstmp and ssmtp is that it maintains a queue of emails to be sent. The application sending the mail is blocked only a very short time while the mail is queued (milliseconds). The sending of the mail happens in the context of a another process.
Solutions like mstmp and ssmtp don't maintain a queue of email. The sending happens in the context of the application, thereby blocking the application. Sending an email this way can easily take 1 to 2 seconds or longer. This may not be a problem in many cases but can become a problem if the email is sent by a web application.
http://untroubled.org/nullmailer/
You do not need a mail transport agent (MTA) instance on the machine doing the sending if you have another mailserver already running in your organization: you can make Perl deliver the email through SMTP to that server, so there's no need for having (another) MTA like sendmail on "your" machine.
I'm fond of creating a gmail or other free account and then using the java mail api in J2EE to send messages (from your new gmail account) to whoever... Typically i'll create a Mailer class which can be constructed with a default constructor and then give it a send(String dest, String subj, String body[, Obj attach...if you want]) and then in your case you might wrap the thing in a main method so that you can call it from else with some command line args, or call from within some java program. If you interested i'll shoot you the code.
I know you said perl, but the simplest cross-platform email sending library I have used is python's smtplib. Certainly worth a look.