Is there a Perl module to monitor an email queue? - perl

I'm working on an issue tracking system and would like the application to handle email replies. That is, I would like a script that can monitor an email queue and perform some action based on the email contents. It should then be able to delete the email, etc.
I currently use MIME::Lite to send email, and I can handle writing the script etc. (read: I'm not new to Perl). However, I have no idea what modules are good for doing this particular task. I'd like to get started on this as quickly as possible so I hope to narrow my search space for possible modules.
In case you need to know, the application will be running on a standard linux, Perl, MySQL stack with Exchange as the mail server.
Can anyone suggest a Perl module to help me out? Any tutorials or best practices related to this would also be helpful.
Thanks!

Do you have access to the Exchange server via IMAP or WebDAV?
For IMAP:
Mail::IMAPClient
IMAP::Client
Net::IMAP::Client
Email::Folder::IMAP
For WebDAV:
Email::Folder::Exchange
POP3 would also be an option if it's enabled on the server. IMAP is probably the way to go if you've got it.

I've done something similar using Mail::POP3Client

The Perl Email Project # http://emailproject.perl.org/mediawiki/index.php/Main_Page has recommendations and other information on the mail oriented modules for perl.

Related

Which library for receiving email, performing actions server side

I would like to implement an email receiving feature similar to the one found at asana.com:
http://asana.com/guide/tags-email/email-incoming
Users can send email to a designated address, and the system will perform actions based on recipient and message contents.
Any recommendations for libraries that handle this?
I see openpop.net, but i wonder if this technology would have a delay since by nature pop doesn't receive mail on its own, you must initiate the request.
Anyway, hoping to get the scoop on this technology from the experts here. Preferably, an answer would direct me to both a library and some tutorial/documentation.
If you're doing this on a Linux box, it's fairly straight-forward to set it up such that incoming emails are piped directly to a script - be it PHP, PERL, etc. See http://harrybailey.com/2009/02/send-or-pipe-an-email-to-a-php-script/ for an excellent article.

Possible to use server for collecting and distributing mail

We currently have POP3 mail accounts where I am and try as I might to convince my manager that we should be using hosted IMAP or Exchange he won't budge because of the cost. The staff are mostly out of office so there is no domain server here, however, we do have a dedicated server and I wondered whether I could use this to collect the mail and distribute it from there in some way.
Effectively what I'm trying to do is ensure mail is stored somewhere other than the end users machine because backups are user dependant at the moment. With hosted Exchange or Exchange on this server would be simple but my manager won't shell out for it. I have seen free mail servers called MailEnable and Axigen but unsure if they will do the job. Sorry if this seems like an easy or stupid question but never needed to do this before.
I am assuming due to the reference to Exchange that you are on Windows.
If you have an old box lying around that works, you could install linux on it and then choose from a number of different imap servers. Dovecot and Courier are both good choices and I have worked with them before.
You could use fetchmail to then pick up the mailboxes and then deliver to the imap boxes or get them deliver directly.
Setting up such a linux server for email was one of the first things I ever did on Linux. While initially daunting, once you get the hang of it, it is pretty straightforward and there are plenty of resources out there to help.
Ubuntu is probably the easiest to get used to. CentOs is also a reasonable choice.
You shouldn't be running your own server if you aren't willing to administer your own server, and they are not easy to configure if you don't know what you are doing (e.g., you mess up and you are exploited for spamming).
Look into a service like mailgun. In my application we are using them for forwarding to REST endpoints as well as onto another SMTP server.
Competitors that wound up not meeting my needs but may meet yours include Dyn, email yak, Sendgrid, etc. etc.
Why not just setup the mail clients to store their mail files on a standard network drive or share? I follow that this situation is pretty silly in your view - 100% because of the ridiculous constraints that you are being asked to work within: I would similarly find the solution I am suggesting ridiculous generally; but under the circumstances, it seems like a simple answer to your problem - replacing distributed mail storage and backup with centralized storage and backup.
Don't POP3 email clients have the option keep a copy on the server? Mine certainly does. See second tick box on the pic.
You can then periodically take a back up of all the emails from the server to stop it getting clogged up.

Is there a Windows utility that can be used to receive mails via POP?

Is there a utility (like Blat) that can be used to receive mail, perhaps via POP?
I need something that's
A Windows Executable (no DLLs)
Simple to use
Doesn't need to be installed
I'm trying to make a simple email interface for my program. Any ideas would be appreciated.
While on the subject, is there a good free email provider that doesn't demand secure logins?
http://www.codeode.com/popclient/index.html

Mail Client without POP or IMAP

My university refused to allow us to access out mail via POP or IMAP etc so I want to write a GTK based C app that sits in my notifcation area and does the job of a mail client notifier. Because I can't use anything like POP or IMAP, what would be a good way to do it? I guess I could scrape the HTML and look for a tag that is only present in unread mail or something?
Any Ideas?
I know you said C/GTK but it's a piece of cake in Python/GTK with urllib2, libcookie, and BeautifulSoup. That way you don't have to deal with raw sockets, and parsing the HTML yourself. Hell if you edit your question with a link to the source I could hack this up for you in no time. But if you're doing this as a socket exercise, more power to you :P
You should note that most server admins don't take too kindly too frequent scraping of their site, and you should probably clear it with them, lest you face the repercussions.
Well yes, if the only way to access your email is through webmail then any tool you create will have to use the webmail markup to work out new messages.
Personally I'd try and find out why POP/IMAP isn't allowed. As far as I'm concerned that's a really strange policy.
In precedent job, the only access we had to email was through a webmail (squirrelmail) at the time, I had wrote a Perl script with WWW::Mechanize that went through the pages to fetch the emails, send them via smtp to an external mailbox, delete them, and expunge the trash...
It's was about 20/25 lines of code. Off course, a C version would be a bit bigger because it would not have WWW::Mechanize :-)

Method for email testing

I am writing a program that will be emailing reports out many (~100) clients which I want to test before I spam everyone.
I want to do a test run against my production data and actually send the messages to a SMTP server, but I don't want the SMTP server to actually deliver the messages. I want the server to act like a real SMTP server from the perspective of my application, but instead of delivering messages, I just want it to store the messages, and log what happened.
Is there a SMTP server specifically designed for testing purposes?
Does anyone know of a way to configure exim or postfix to behave like I have described above
What do you use to test a mass-email delivery?
In java you can use dumbster
Its easy to use and you can validate every aspect of the email you are intercepting.
It's a Java SMTP server implementation meant for unit testing. (Just make sure you redirect your email to the machine running dumbster...)
I just found another alternative that do almost the same: Greenmail
Greenmail also support POP3, IMAP with SSL so you can test your client against it.
For .NET I set the config file to deliver mail to a folder, then you can have the automated test inspect the directory and files.
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\pickupDirectory"/>
</smtp>
</mailSettings>
</system.net>
While searching for options I found the following that may be useful.
DevNullSmtp
Use a null SMTP server for testing
Fake SMTP Service
twisted examples/emailserver.tac
"The Wiser framework for unit testing mail"
I've heard of a few other developers moving from Dumbster to Wiser and have migrated my testing code as well. One of the Java components that I've worked on sends thousands of emails a day and I've written unit tests for the different email templates and scenarios using Dumbster and Wiser. I prefer Wiser.
Snips from the Wiser website (http://code.google.com/p/subethasmtp/wiki/Wiser):
Wiser is a smart replacement for Dumbster and is built on top of the SubEtha SMTP Java library which allows your Java application to receive SMTP mail with a simple, easy-to-understand API.
A good program for email testing is smtp4dev (Windows only).
It's a dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected.
http://smtp4dev.codeplex.com/
http://skaraarslan.blogspot.com/2008/02/how-to-check-email-works-without-using.html
(this presumes you are using .net to send emails)
Given that you mention exim and postfix (which I'm taking to be some kind of unix stuff), this answer might not be as useful as it could be, but check out Neptune. It's a fake SMTP server designed for automated testing. If you've got a spare windows box floating around, you could put Neptune on that then configure your app to send "through" the Neptune server.
Exim can be configured to accept incoming mails but not deliver them. Look for the keywords queue_only and queue_only_file in the documentation.
I personally modify the e-mail addresses to test, I send them to a dummy account of mine, that way I can validate not only that they sent, but that they appear in the proper format.
At my office, we have a server that is set up to always send all incoming mail to one address, regardless of who it's actually addressed to. We just point all our testing environments at that server and watch the QA mailbox fill up. I don't know what server it is, but it's probably some open source thing someone found.
Sendmail has a Test Mode.
You just invoke sendmail with the -bt parameter. As an example:
/usr/lib/sendmail -bt -Ciu-testconfiguration.cf
Please be aware that in this method, Sendmail requires an special configuration on rewrite rules. You need to understand how Sendmail rewrites addresses in order to properly create a .cf file for Test Mode.
Edit: See this article: http://ussg.iu.edu/usail/mail/debugging/
After not beeing happy with the solutions I found, I ended up writing developmentSMTP, easy to use, 100% Java --> cross platform.
Supports writing emails to file, forwarding emails or simply printing them on stdout.
Post Hoc is a pure Java application that looks exactly like an SMTP server to the application you are testing, but it simply collects all the email messages and allows you to inspect them using a web interface.
Freely available at: Post Hoc GitHub Site
For more information: PostHoc: Testing Apps that Send Email
If you're looking to manually test that the email sends and that the email template has the right kind of html and css that you're expecting, then I would recommend maildev https://www.npmjs.com/package/maildev. You can install and run it as a node module and also as a docker container! I've found it extremely handy for basic sanity testing of emails.