Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Mail::Sender Problems.

by Steve_BZ (Hermit)
on Aug 09, 2012 at 08:56 UTC ( #986450=perlquestion: print w/ replies, xml ) Need Help??
Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm using Mail::Sender to send emails automatically from my application: it's a very nice little tool.

However I have a problem in that, depending on the setup (ie ISP/router), sometimes it works and sometimes the connection times out (Error connect() failed: Connection timed out. However other email clients do work.

I have extracted a bit of the code into a standalone application which reproduces the problem. However the debug file remains resolutely empty.

#!/usr/bin/perl -w use strict; use Mail::Sender; my $sender = new Mail::Sender { auth => 'PLAIN', authid => 'user', # Change this. authpwd => 'password', # Change this. smtp => 'smtpserver.mydomain.com', # Change this. from => 'user@mydomain.com', # Change this. to => 'foo.bar@yourdomain.com', # Change this. subject => 'test subject', msg => 'This is a text email', file => '/home/foo/bar/default.pdf', debug => "/home/foo/bar/SendMailDebug.txt", debug_level => 4, timeout => 500, }; my $result = $sender->MailFile({ msg => $sender->{msg}, file => $sender->{file}, }); print "$sender->{error_msg}\n>>>End.\n"; 1;

Am I using it right?

How can I get the debug function to give me something useful?

Any other ideas.

Regards

Steve

Comment on Mail::Sender Problems.
Select or Download Code
Re: Mail::Sender Problems.
by flexvault (Parson) on Aug 09, 2012 at 10:28 UTC

    Steve_BZ,

    I have not used 'Mail::Sender', but if your not getting errors from Perl than you need to look at the log files for the mail deamon (MTA).

    Another thought!

    If it works sometimes, and your timing out, maybe the mail server your contacting is not available to the Internet. A common technique to force all mail through a 'spam scanner', is to disable (firewall) any SMTP connection from the Internet, so that the second/third/... 'MX' DNS record is used which will point to the spam checking machine(s).

    After checking the mail, and if the email passes for 'non-spam', the scanner sends the email to the first 'MX' record. You can fix that by sending the email to a local Mail Transport Agent (MTA) like 'sendmail' which will try all MX records until a successful delivery.

    Good Luck

    "Well done is better than well said." - Benjamin Franklin

Re: Mail::Sender Problems.
by zentara (Archbishop) on Aug 09, 2012 at 10:33 UTC
    depending on the setup (ie ISP/router), sometimes it works and sometimes the connection times out (Error connect() failed: Connection timed out.

    Could it be the port number the mail server is using? Many SMTP servers are now using something other than port 25 to get around some ISP's who block port 25.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      zentara,

      Most ISPs give an alternate port( i.e. 587, ... ) to their own users.

      MTA to MTA traffic is on port 25, but many ISPs firewall port 25 to a spam/virus scanning machine(s), and use DNS 'MX' magic to make it work!

      If an ISP completely blocked port 25, they wouldn't have many emails to worry about.

      "Well done is better than well said." - Benjamin Franklin

        Hi Flex, Hi Zentara, Hi rpnoble419,

        Well the general advice seems to be try another port, it sounds like good advice. I'll try one later today.

        Another piece of info is that my current router is a '3' MyFi router (ie a sim card), so I guess ISP's spamming restrictions maybe harsher, I recall that when I used a t-mobile data card, they had to provide me with an smtp server, maybe 3 is the same, I'll check it out.

        Regrads

        Steve

Re: Mail::Sender Problems.
by rpnoble419 (Pilgrim) on Aug 09, 2012 at 10:35 UTC
    try setting the port. In some cases I have found that Mail::Sender can be blocked by a hosts mail filter. My host has given me a port number that is not scanned and therefore my emails are not blocked. You may also want to try
    auth => 'LOGIN', port => Port Number,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-10-22 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls