Was looking around for the easiest way to send email with Perl on ubuntu.
First, we need to make sure that
smtp server is running. To check if it is already running, use this command:
nmap localhost | grep smtp
If that returns a line like:
25/tcp open smtp
then smtp is running. Otherwise execute:
sudo apt-get install postfix
(following http://my.opera.com/Contrid/blog/show.dml/478684) and accept the defaults (or set them).
#!/usr/bin/perl -w use Mail::Sendmail; sendmail( From => 'email@example.com', To => 'firstname.lastname@example.org', Subject => 'You got it!', Message => "Now you know how to send mail!", );
Of course, if the module is not installed, we get the following error:
Can't locate Mail/Sendmail.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at FILENAME.pl line XXX.
BEGIN failed--compilation aborted at FILENAME.pl line XXX.
You will need to install
sudo apt-get install libmail-sendmail-perl
If after that, you get another error like this complaining that
MIME::Lite is missing:
Can't locate MIME/Lite.pm in @INC (you may need to install the MIME::Lite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at ../util/mail_util.pm line 4.
sudo apt-get install libmime-lite-perl