From owner-freebsd-questions@FreeBSD.ORG Sun May 6 19:29:07 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 23B6616A402 for ; Sun, 6 May 2007 19:29:07 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout2.cac.washington.edu (mxout2.cac.washington.edu [140.142.33.4]) by mx1.freebsd.org (Postfix) with ESMTP id 020D513C457 for ; Sun, 6 May 2007 19:29:06 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.141] (may be forged)) by mxout2.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l46JT6xA019911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 6 May 2007 12:29:06 -0700 X-Auth-Received: from [192.168.10.45] (c-67-187-164-17.hsd1.ca.comcast.net [67.187.164.17]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l46JT5Tr003913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 6 May 2007 12:29:05 -0700 Message-ID: <463E2CA7.5040009@u.washington.edu> Date: Sun, 06 May 2007 12:29:43 -0700 From: Garrett Cooper User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Jeffrey Goldberg References: <463DF8B5.5000906@oregnier.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.3.1.294258, Antispam-Engine: 2.5.1.298604, Antispam-Data: 2007.5.6.121536 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Cc: Olivier Regnier , freebsd-questions@freebsd.org Subject: Re: sending email with perl X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2007 19:29:07 -0000 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 =>'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 An even easier way is to use /usr/bin/mail from Perl, similar to the following: system("/usr/bin/mail -s 'Subject line' recipient@foo.com < 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