tags:

views:

528

answers:

7

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.

A: 

I know you said perl, but the simplest cross-platform email sending library I have used is python's smtplib. Certainly worth a look.

Simon
+3  A: 

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.

kmkaplan
A: 

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.

ShiDoiSi
bad advice! a local mta spools messages, handles errors, retries delivery in case something goes wrong. all this your application would have to do itself if it talked smtp to a remote server.
hop
I disagree: a local MTA requires administration. If it is not properly done, this will just brush any problems under the carpet. I don't see anything wrong with delivering to a smarthost. If the smarthost has a problem, you just need minimal intervention/error handling on the Perl side.
ShiDoiSi
a unix system without a working (outgoing) mta is not a properly configured unix system anyway! it's not just your little application that wants to send email: there's all sorts of cron jobs, etc that depend on it. on most linux distribution you can't even deinstall the mta without a --force.
hop
also, configuring nullmailer takes exactly one entry for the admin address and one for the relay host. how much code does your "minimal" handling take, even in perl?
hop
There's no difference in checking the exit code of /usr/lib/sendmail or that of the perl library, error handling is required in both cases.
ShiDoiSi
but sendmail will return an error far less often, if ever. compare that to all the things that can go wrong with an smtp session.
hop
+2  A: 

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

chburd
for this kind of application, something even simpler than postfix or qmail would probably be better. look into nullmailer, mstmp, ssmtp, etc.
hop
A: 

Am I the only one who's thinking "amateur spammer"?

catfood
Probably - I was thinking of a notification email for an admin. There's a whole lot of reasons to send a "one-off" email, and most of them are good.
David Thornley
+1  A: 

I have used msmtp successfully, ie it supports great authentication

epatel
A: 

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.

sweeney