Way to delay SMTP pickup outgoing mail - email

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 :)

Related

Difference between CDO.Message and System.Net.Mail

I've implemented email blasting system with C#.net application using System.Net.Mail.
Previously, this system was implemented with VB Script using CDO.Message.
After I deployed my new system and run it for blasting(sending emails), I got the exception(Error in processing Number of messages exceeds maximum per connection) in production SMTP Server.
I know that this error is because of the SMTP server setting, but my client argues that the previous VB script can work with this SMTP Server setting.
That's why I want to know the difference between CDO.Message and System.Net.Mail, for instance, is there control of connection sessions, etc.
Please kindly advise me. Thanks.
'CDO' is a COM implementation for sending mail whereas 'System.Net.Mail' is a managed way to send mail using SMTP (which is typically a relay to another mail server). You are likely to find limitations in sending a larger number of concurrent emails with both as a server can only handle so many. Concurrent requests - similar to a highway only being able to handle a finite number of cars at any one time.

What's the easiest way to process incoming email and add it to a queue on a Linux server?

What's the easiest way to process incoming email? Our objective is to get email into a Resque queue. We've explored and integrated a lot of options, like piping email through Postfix into Ruby (which turned out to be unreliable), piping email through Google App Engine back to our server (which turned out to be shaky), and using Sendgrid (which is expensive.)
I'm trying to explore other ways to get email processed. Any ideas?
If the email is received and hosted by an IMAP-capable server (Gmail is good enough), then the messages can be retrieved and processed once and again from almost any programming language using standard libraries.

Is an e-mail queue necessary in an e-mail-heavy web app?

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.

trigger a script when mailbox recieves mail?

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.

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.