Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Connect to an SMTP Server that Requires Authentication

by batkins (Chaplain)
on Jul 13, 2003 at 20:11 UTC ( #273815=snippet: print w/replies, xml ) Need Help??
Description: It took me a bit to finally find code that works for this, so here's hoping this will help you out. The code will connect to an SMTP server and send a message off. Some SMTP servers require your full e-mail address, while others require only your username. Try both until it works.
sub sendmail
    my $smtp = Net::SMTP->new('servername',
                              Hello => 'hellodomain');

    $smtp->auth('username', 'password');

    $smtp->datasend("To: ... \n");
    $smtp->datasend("From: ... \n");
    $smtp->datasend("Subject: ...\n");

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://273815]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2016-10-28 01:51 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (374 votes). Check out past polls.