Perl - Sending Email
How can we use MIME::Lite to send email?
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Lite ();
my $data = "Body of email";
my $msg = MIME::Lite->new(
From => 'khai@genius.com',
To => 'khai@genius.com',
Cc => 'khai@genius.com',
Subject => 'Blah Blah',
Type => 'text/html',
Data => $data
);
$msg->send('smtp','127.0.0.1');
How can we use sendmail to email the form data?
use CGI;
$q = new CGI;
$from = $q->param('from');
$name = $q->param('name');
$to = $q->param('to');
$subject = $q->param('subject');
$message = $q->param('message');
open(SENDMAIL, "|/usr/bin/sendmail -t -n");
print SENDMAIL << end_of_mail;
From: $from <$name>
To: $to
Reply-To: $from
Subject: $subject
$message
end_of_mail
How can we use Net::SMTP?
use Net::SMTP;
my $smtp = Net::SMTP->new(
'xyz.com',
'Hello' => 'mail.mydomain.com',
Timeout => 30,
Debug => 1
);
$smtp->mail($mailfrom,
$smtp->reset();
$smtp->recipient($address, SkipBad => 0, Notify => );
$smtp->data()
$smtp->datasend($data);
$smtp->dataend();
$smtp->quit();
page revision: 4, last edited: 13 Apr 2016 11:09