2

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.

7 Answers 7

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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

1 Comment

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

I have used msmtp successfully, ie it supports great authentication

TJ Luoma did a nice writeup of it on TUAW

Comments

1

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/

1 Comment

Installing nullmailer on unbuntu: ubuntublog.ch/applikationen/nullmailer-unter-ubuntu (german article but commands should be understandable by anyone)
0

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.

7 Comments

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.
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.
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.
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?
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.
|
0

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.

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.