Friday, October 5, 2012

Send email with Perl using SMTP with login/password authorization

Here is the working Perl script to send email using SMTP with login/password authorization.

It'll work if you run from your PC or webhosting server.


#!/usr/bin/perl

use Net::SMTP;

$smtp = Net::SMTP->new('mail.d********ia.com'); $smtp->auth( 'conta******dia.com', 'passw***' ); $smtp->mail('contactus@do***********.com'); $smtp->to('ra******@gmail.com');

$smtp->auth( 'conta********dia.com', 'passw***' ); $smtp->data(); $smtp->datasend('ra******@gmail.com'); $smtp->datasend("From: Whats up?\n"); $smtp->datasend("To: Whats up?\n"); $smtp->datasend('Subject: Whats up1?'); $smtp->datasend("\n"); $smtp->datasend("See, I mailed you through my program.\n"); $smtp->dataend();

$smtp->quit;

No comments:

Post a Comment