Logo
  • Home
  • About
  • Services
  • Blogs
  • Career
  • Contact
Logo

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

  • Address

    4th Floor, 4 Tabernacle Street London EC2A 4LU
  • Email

    info@podtech.com
  • Contact

    +44 (0) 20 8720 6583

Perl – Sending Email with NET::SMTP using username and password

  • Home
  • Perl – Sending Email with NET::SMTP using username and password
  • By podtech
  • In Perl

Perl – Sending Email with NET::SMTP using username and password

First of all double check that Authen::SASL is an installed module.. If you are not getting emails this could be why – it doesnt provide an error that is understandable!

#!/usr/bin/perl
### ENSURE Authen::SASL is installed
use Net::SMTP;
use strict;
use warnings;

my $host= ‘yourhostname’;
my $username= “yourpop3username”;
my $password = “yourpassword”;

my $from = ‘bob\@GOemail.com’;
my $to = ‘bob@here.co.uk’;
my $DOMAIN = “somedomain.co.uk”;

my $smtp = Net::SMTP->new($host, Hello =>$DOMAIN, Timeout => 60) or die “Failed to Open SMTP Connection : $!”;
$smtp->auth($username, $password) or die “Failed to authenticate”;

my $subject = “Build”;
my $emailBody = “This is the body…\n BOB”;

$smtp->mail(“$from”); ## FROM
$smtp->to(“$to”);
$smtp->data();
$smtp->datasend(“To: $to\n”);
$smtp->datasend(“From: $from \n”);
$smtp->datasend(“Subject: $subject \n”);
$smtp->datasend(“\n”);
$smtp->datasend(“$emailBody:\n”);
$smtp->datasend(“\n”);
$smtp->dataend();
$smtp->quit;

These links were useful also:

http://quark.humbug.org.au/publications/perl/perlsmtpintro.html

http://www.perlmonks.org/?node_id=449583

http://search.cpan.org/~shay/libnet-1.27/Net/SMTP.pm

NETPerlSending Email with NETSending Email with NET::SMTPSMTP
Fix Open Postfix Relay – Unauthenticated Email
Quick – Install Package on a Firewalled Server

Recent Posts

  • What is Software Piracy?
  • Microsoft and SITA Launch New Innovation Center in South Africa
  • Ericsson, Qualcomm and Thales to Launch 5G into Space
  • Schneider Electric Launches Free Data Center Professional Education Platform
  • UK and South Korea Reach Data Sharing Agreement

PodTech IO

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

Company

  • About
  • Services
  • Contact
  • Blogs
  • Career

Terms

  • Terms & Conditions
  • Privacy Policy

Contact Us

  • ADDRESS

    Headquarter: Tabernacle Street London India: Vi john Tower, Gurgaon, Haryana
  • EMAIL

    info@podtech.com
  • CONTACT

    +44 (0) 20 8720 6583

Copyright ©2022 PodTech IO. All Rights Reserved

Logo