[San-Diego-pm] Mail::Sender

Chris Grau chris at chrisgrau.com
Sat May 12 12:10:37 PDT 2007


On Sat, May 12, 2007 at 11:48:40AM -0700, Joel Fentin wrote:
> Chris Grau wrote:
> > On Sat, May 12, 2007 at 10:31:26AM -0700, Joel Fentin wrote:
> >> I'm looking for a way of emailing with attachments. Since
> >> Mail::Sender is already installed in my account, this where I
> >> started. I've been running lots of variations of the below. They
> >> run to the end without errors. But they don't send any emails.
> > 
> > I've never used this particular module, but my brief scan of the
> > documentation tells me that you appear to be using it correctly.
> > 
> >> my $sender = new Mail::Sender({
> >> smtp => 'smtp.nethere.net',
> >> from => 'avocado at nethere.com',
> >> }) or die "Error in mailing : $Mail::Sender::Error\n";
> > 
> > I assume the SMTP server is correct.  What happens when you try to
> > speak to it via telnet?  It may be fine, but this is where I always
> > start with mail problems.
> 
> Telnet? Speak to what? How? Would the host let me?

[cgrau at anubis ~]$ telnet smtp.nethere.net 25
Trying 66.63.128.171...

It hangs for me.

> I don't really know if the SMTP is correct. I have two that seem to
> work with this email client (thunderbird). smtp.vcweb.org (microwave
> link from my house to Mt. Palomar) and smtp.nethere.net (my service
> provider). I've tried both. My website is hosted by bulletweb. Not
> sure if I need another smtp.

If smtp.nethere.net is from your service provider, it most likely only
works on their network.  I'm going to assume your web host is not on a
local machine on your service provider's network.  If so, you'll need to
determine the correct SMTP host to use.

> Also, in some of the examples I saw on line, the smtp => was omitted.

This usually means the module will use localhost, which in the *nix
world is usually the right thing to do.  Try it, see if it works.

> > Have you tried checking the results of each method call?  According
> > to the documentation:
> > 
> >     Returns the Mail::Sender object if successfull, negative error
> >     code if not, zero if $sender was not connected at all. The zero
> >     usualy means that the Open/OpenMultipart failed and you did not
> >     test its return value.
> > 
> > Looks like you can configure the Mail::Sender object to die on
> > error.  That might be useful for debugging.
> 
> Not quite sure if I get what you are saying.
> I changed the last line from $sender->Close;
> to:
> $sender->Close or die "Failed to send the message: 
> $sender->{'error_msg'}\n";
> 
> The result was the following:
> Failed to send the message: Connection not established

Appears to be the same behavior I experienced with my telnet command.

> I also put an error trap in the openmultipart statement but didn't get
> an error there.

My reading of the documentation tells me that the connection to the SMTP
host doesn't occur until the Close() method is called.  So you wouldn't
get an error from an earlier method call for an invalid SMTP host.

-- 
Chris Grau
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/san-diego-pm/attachments/20070512/6a176f79/attachment.bin 


More information about the San-Diego-pm mailing list