cain All American 7450 Posts user info edit post |
anyone done this before ? 11/8/2007 10:25:38 AM |
bous All American 11215 Posts user info edit post |
no one on google has ever done this. 11/8/2007 10:32:03 AM |
joe17669 All American 22728 Posts user info edit post |
ive seen people do it, but they always use a call to sendmail i think 11/8/2007 10:35:43 AM |
WolfAce All American 6458 Posts user info edit post |
there's a perl module for everything, check CPAN 11/8/2007 10:42:48 AM |
cain All American 7450 Posts user info edit post |
I know people on google have done this. i was wondering if anyone here had, and had a code snipet or a few seconds.
all the stuff i find on google seems in reference to mailing based off web page imput/triggers. i am looking do do this all inside a stand alone script. I do my ./foo.pl and it emails out its findings.
i have an array of recipients and a message already created, just need to send it out.
Thanks for the CPAN point, works fine now
[Edited on November 8, 2007 at 10:54 AM. Reason : a] 11/8/2007 10:47:29 AM |
Shaggy All American 17820 Posts user info edit post |
mail dude <thing
[Edited on November 8, 2007 at 11:03 AM. Reason : stupid premie] 11/8/2007 11:02:30 AM |
evan All American 27701 Posts user info edit post |
this has never been done 11/8/2007 11:38:00 AM |
chicago_fats Veteran 228 Posts user info edit post |
use Net::SMTP;
send_mail('smtp.ncsu.edu', 'sender@ncsu.edu', 'recipient@ncsu.edu', 'Test Subject', 'Test Body');
sub send_mail { my ($smtp_server, $sender, $recipient, $subject, $body) = @_; my $smtp; # Connect to the SMTP server $smtp = Net::SMTP->new($smtp_server); # Configure the sender's address $smtp->mail($sender); # Configure the recipient's address $smtp->to($recipient); #Start the data $smtp->data();
# Send the header. $smtp->datasend("Subject: $subject\n"); $smtp->datasend("To: $recipient\n"); $smtp->datasend("From: $sender\n"); $smtp->datasend("\n");
# Send the body. $smtp->datasend($body);
# Finish sending the mail $smtp->dataend(); # Close the SMTP connection $smtp->quit; } 11/8/2007 11:49:49 AM |
cain All American 7450 Posts user info edit post |
thanks to the helpful people, got it working.
and thanks for being jackasses tot he jackasses 11/8/2007 12:03:57 PM |
joe17669 All American 22728 Posts user info edit post |
^^ does that use sendmail, or does perl have it's own mailer? ive never used perl, but i always had friends use sendmail 11/8/2007 12:10:38 PM |
Shaggy All American 17820 Posts user info edit post |
i would imagine it would use whatever the default mailer on the system is.
[Edited on November 8, 2007 at 12:23 PM. Reason : or it might be its own mailer.] 11/8/2007 12:23:04 PM |
evan All American 27701 Posts user info edit post |
pretty sure it uses sendmail 11/8/2007 12:24:03 PM |
chicago_fats Veteran 228 Posts user info edit post |
Net::SMTP does not use sendmail. It works on Windows without having to install any sendmail equivalents like blat or a sendmail port. There are several other ways to send mail via Perl and you'll probably want to look at something else if you're messing with MIME types and attachments. I use the subroutine posted above to mail log files and alerts to myself and other administrators. 11/8/2007 3:34:35 PM |