|laziness, impatience, and hubris|
Ultimail.pm : A module to send an email without your ISP's mailserverby gaggio (Friar)
|on Jul 28, 2000 at 18:15 UTC||Need Help??|
Well, I could have probably posted this in the Code Catacombs section, but I do think that it is also a Cool Use for Perl, even a small revelation for some people...
Indeed, there were mail sending modules available (Mail::Mailer, Net::SMTP, etc.), and there was the mail program forking method (e.g. open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq"), etc.). Those methods are not as simple as sending an email could be, because you need to have a mailserver to route your email through the Internet (I am not even talking about the Win32 case, where you need to get some sort of sendmail replacement to work along with those modules...).
Well, maybe that Ultimail.pm is for you, then, since the only thing it requires is to have an Internet connection, which you have obviously since you are reading this :-)
I can see already some people coming and telling me that it is not "the holiest way" to send email, because the netiquette or "net moral policy" forbids it. Well, first, I am not the only one to send email like this (have a look here, for example, where you can download and use for FREE an application to send your email directly to your target email address from a Microsoft platform). Second, I don't understand why sending emails that way would perturb in any way the way the Internet is working. I think that no harm can be done by bypassing your ISP, when you can: it just makes the route of the emails shorter, in fact!
There is not lots of technology behind Ultimail. It simply uses a raw socket connection to talk directly to the server of the email receiver, after having fetched this server name in the DNS records.
Warning: Althoug I did not have any problem using the module myself, I do *not* guarantee that sending emails that way will work always. Simply because it is possible that some email servers would performs special checks during the communication. For example, if you want to send an email with a "From:" field claiming that you are "JuliaRoberts@UniversalStudios.com" - a fake email address for the sender - you might find your sending request denied.
So, here you are, excited about such possibilities, and want to use the Ultimail.pm module. How can you do that? - Easy. First, go to my homepage, follow the link to the Perl section, download the module, unzip it, and put it in your library directory. Note that to get the program to run, you will have to install the Net::DNS module. The Net::DNS Author can be found here. If you are on a Microsoft platform, you should download the latest development version, to avoid problems. Then, code! Here's a self explanatory example program:
There are other features in the module, like the possibility to display the communication, with the verbose() method, or the possibility to give a "ReplyTo" email address different from the sending address, but I leave this undocumented here, to keep it simple: just read the code by yourself!
Ultimail.pm does not support Attachments, yet. Feel free to add the feature to the module, if you want - you will certainly need to use an encoding library. But in this case, please email me: I'd be glad to see your improvements in action!