If your providers server listens on port 465 (as indicated in the code snippet above), it almost certainly expects an SSL connection (465 is the universally accepted port for SMTPS,i.e. SMTP over SSL). AFAIK you can't use SSL in conjunction with the MIME::Lite send() method (or rather, you probably could but it's more trouble than it is worth), so you'll need to use something like Net::SMTP::SSL for sending. You can still use MIME::Lite for constructing the message. For example (untested):
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Lite::TT::HTML;
use Net::SMTP::SSL;
my %params;
my %options;
$options{INCLUDE_PATH} = 'c:/Documents and Settings/Uriel/My Documents
+/Sandbox/perl/';
my $msg = MIME::Lite::TT::HTML->new(
From => 'admin@example.com',
To => 'test@yahoo.com',
Subject => 'Hello world',
Template => {
text => 'test.txt',
html => 'test.html',
},
TmplOptions => \%options,
TmplParams => \%params,
);
my $smtp;
$smtp = Net::SMTP::SSL->new($host, Port=>465) or die "Can't connect";
$smtp->auth($user, $pass) or die "Can't authenticate:".$smtp->message(
+);
$smtp->mail('admin@example.com') or die "Error:".$smtp->message();
$smtp->to('test@yahoo.com') or die "Error:".$smtp->message();
$smtp->data() or die "Error:".$smtp->message();
$smtp->datasend($msg->as_string) or die "Error:".$smtp->message();
$smtp->dataend() or die "Error:".$smtp->message();
$smtp->quit() or die "Error:".$smtp->message();
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|