Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env perl
- use feature qw(say);
- use strict;
- use warnings;
- use utf8;
- use Authen::SASL qw(Perl);
- use Net::SMTP 3.0;
- my $smtp = Net::SMTP->new(
- 'smtp.gmail.com',
- SSL=>1,
- Timeout => 20,
- Debug => 1,
- );
- die "Initialization failed: $!" if !defined $smtp;
- my $sender = my $user = 'hakon.hagland@gmail.com';
- my $password = '????';
- say "Trying to authenticate..";
- my $auth_res = $smtp->auth( $user, $password);
- say "could not authenticate\n" if !$auth_res;
- my $receiver = 'hakon.hagland@gmail.com';
- $smtp->mail( $sender );
- $smtp->to( $receiver );
- $smtp->data();
- $smtp->datasend( "To: $receiver\n" );
- $smtp->datasend( "From: $sender\n" );
- $smtp->datasend( "Content-Type: text/html\n" );
- $smtp->datasend( "Subject: Testing Net::SMTP" );
- $smtp->datasend( "\n" );
- $smtp->datasend( 'The body of the email' );
- $smtp->dataend();
- $smtp->quit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement