Re: sending email with perl

2007-05-06 Thread Jeffrey Goldberg

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 ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
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 [EMAIL PROTECTED] -h ssl0.ovh.net -d elipse -p  
465 -U [EMAIL PROTECTED] -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 Goldberghttp://www.goldmark.org/jeff/

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: sending email with perl

2007-05-06 Thread Garrett Cooper

Jeffrey Goldberg wrote:

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 ='[EMAIL PROTECTED]',
To ='[EMAIL PROTECTED]',
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 [EMAIL PROTECTED] -h ssl0.ovh.net -d elipse -p 
465 -U [EMAIL PROTECTED] -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


An even easier way is to use /usr/bin/mail from Perl, similar to the 
following:


system(/usr/bin/mail -s 'Subject line' [EMAIL PROTECTED]  
Email_Contents_In_A_File);

That way you don't have to sent anything up for Perl specifically every 
script, and your .mailrc settings are there to be used (at your 
discretion -- I believe you can turn them off :)..).


The only thing this doesn't do is attachments, but I think that requires 
a bit more work...


Cheers,
-Garrett
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]