in reply to emailing with attachments
sub sendSMTPMail { # send a mail with SMTP server # parameters: # 0 : smtp (outgoing) mailserver # 1 : smtp user login # 2 : smtp user password # 3 : sender name # 4 : sender email # 5 : recipient email # 6 : message subject # 7 : email message my $server = shift; my $user = shift; my $pass = shift; my $sendername = shift; my $senderemail = shift; my $recipient = shift; my $subject = shift; my $message = shift; print "server:$server<br />\n"; print "user:$user<br />\n"; print "pass:$pass<br />\n"; print "sendername:$sendername<br />\n"; print "senderemail:$senderemail<br />\n"; print "recipient:$recipient<br />\n"; my $smtp = Net::SMTP->new($server); if ( $smtp ) { $smtp->auth("$user","$pass"); $smtp->mail("$senderemail"); $smtp->recipient($recipient); $smtp->data(); $smtp->datasend("To: $recipient\n"); $smtp->datasend("From: \"$sendername\" <$senderemail>\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("\n"); $smtp->datasend("$message\n"); $smtp->dataend(); $smtp->quit; } else { print "Could not contact smtp mail server $server\n"; } }
|
|---|