Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 May 2007 11:58:19 -0500
From:      Jeffrey Goldberg <jeffrey@goldmark.org>
To:        Olivier Regnier <oregnier@oregnier.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: sending email with perl
Message-ID:  <BC0926BC-4135-4492-B496-17C13F735E14@goldmark.org>
In-Reply-To: <463DF8B5.5000906@oregnier.net>
References:  <463DF8B5.5000906@oregnier.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On May 6, 2007, at 10:48 AM, Olivier Regnier wrote:

> Hello,
>
> I written a small script in perl to send email.
>
> Here is the code:
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use MIME::Lite;
>
> my $msg = new MIME::Lite
> From =>'me@domain.tld',
> To =>'me@domain.tld',
> Subject =>'test',
> Type =>'TEXT',
> Data =>'Hello this is a test';
> $msg -> send;
>
> I have a .mailrc file :
> set sendmail="/root/scripts/nbsmtp.sh"

Perl isn't going to know or care about what is in your .mailrc file.

You should replace

   $msg -> send

with something like

   $msg -> send || die "Could not send: $!"

to at least get some idea of where the send attempt is failing


> I installed a small mta nbsmtp and i use a shell script called  
> nbsmtp.sh with this line :
> /usr/local/bin/nbsmtp -f me@domain.tld -h ssl0.ovh.net -d elipse -p  
> 465 -U postmaster@domain.tld -P password -M l -s -V

I don't know anything about nbsmtp, but if it sets up an SMTP daemon  
on localhost then you can use the perl module Mail:Mailer to set up  
the mailer with something like

   $mailer = new  Mail::Mailer 'smtp', Server => 'localhost' ;

-j


-- 
Jeffrey Goldberg                        http://www.goldmark.org/jeff/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BC0926BC-4135-4492-B496-17C13F735E14>