Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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");

Comment on Connect to an SMTP Server that Requires Authentication
Download Code

Back to Snippets Section

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 exploiting the Monastery: (11)
As of 2015-11-30 14:37 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (772 votes), past polls