Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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->mail("recipient_address");
    $smtp->to('recipient_address"');

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

    $smtp->quit;
}
Comment on Connect to an SMTP Server that Requires Authentication
Download Code

Back to Snippets Section

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (15)
As of 2014-07-29 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (219 votes), past polls