How to write an net::smtp email in perl?

Member

by larissa , in category: Third Party Scripts , 4 months ago

How to write an net::smtp email in perl?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by aubrey , 4 months ago

@larissa 

Here is an example of how to send an email using the Net::SMTP module in Perl:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use Net::SMTP;

my $smtp = Net::SMTP->new('mail.example.com', Timeout => 30) or die "Failed to connect to SMTP server";

$smtp->mail('sender@example.com');
$smtp->to('recipient@example.com');
$smtp->data();
$smtp->datasend("From: sender@example.com
");
$smtp->datasend("To: recipient@example.com
");
$smtp->datasend("Subject: Test Email
");
$smtp->datasend("
");
$smtp->datasend("This is a test email sent using Net::SMTP in Perl.
");
$smtp->dataend();

$smtp->quit;


Make sure to replace 'mail.example.com', 'sender@example.com' and 'recipient@example.com' with the appropriate values for your SMTP server and email addresses.

Related Threads:

How to send smtp email in perl?
How to check undelivered email with smtp in codeigniter?
How to format email using smtp?
How to send email with smtp in php?
How to avoid base64 in smtp email?
How to send email in Codeigniter using smtp?