O'Reilly logo

Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth Edition by Paul Hudson, Andrew Hudson, Matthew Helmke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending Mail

You can get Perl to send email in several ways. One method that you see frequently is opening a pipe to the sendmail command and sending data to it (shown in Listing 40.5). Another method is using the Mail::Sendmail module (available through CPAN), which uses socket connections directly to send mail (as shown in Listing 40.6). The latter method is faster because it does not have to launch an external process. Note that sendmail must be running on your system for the Perl program in Listing 40.5 to work.

LISTING 40.5 Sending Mail Using Sendmail

#!/usr/bin/perlopen (MAIL, "| /usr/sbin/sendmail -t"); # Use -t to protect from usersprint MAIL <<EndMail;To: you\From: me\Subject: A Sample Email\nSending email ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required