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

Email beyond Domain

by Pearl79 (Initiate)
on Nov 19, 2008 at 01:11 UTC ( [id://724440]=perlquestion: print w/replies, xml ) Need Help??

Pearl79 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks- I am using Mail::Sendmail to send email from my script. It only works if I send to addresses on our domain (my co-workers). I cannot send out to my personal email address (like hotmail or yahoo). I don't know much about smtp or email in general. Does anyone have any ideas for how to approach this issue?
#!c:/Perl/bin/perl.exe -w use strict; use Mail::Sendmail; my $recipient = 'me@hotmail.com'; my $sender = 'me@officedomain.com'; my %mail = ( From => $sender, To => $recipient, Subject => "I'm sending you mail", Message => "This is the message body\n", smtp => 'smtp.officedomain.com' ); sendmail (%mail) or die "sendmail failure sending to $mail{To}: $!\n"; print "End of program.\n"; exit(0);

Replies are listed 'Best First'.
Re: Email beyond Domain
by Jenda (Abbot) on Nov 19, 2008 at 01:43 UTC

    Maybe you have to authenticate with the mail server before it accepts messages to addresses outside the company. Have a look at your email client's settings and see the $mail{auth} option of Mail::Sendmail.

Re: Email beyond Domain
by hangon (Deacon) on Nov 19, 2008 at 01:49 UTC

    You probably need to authenticate with the mail server, which going by a cursory look at the docs, Mail::Sendmail does not seem to support. You might want to take a look at Mime::Lite or Mail::Sender.

      Its listed as a LIMITATION No suport for the SMTP AUTH extension.
Re: Email beyond Domain
by ig (Vicar) on Nov 19, 2008 at 03:58 UTC

    If delivery to mailboxes on the mail server (smtp.officedomain.com) is successful, then you probably don't have server authentication issues. More likely is that the SMTP interface at smtp.officedomain.com is configured to accept email to local accounts and to refuse to relay email to other mail servers.

    You should check $Mail::Sendmail::error and $Mail::Sendmail::log after sending:

    sendmail (%mail) or die "sendmail failure sending to $mail{To}: $!\n\$ +Mail::Sendmail::error: $Mail::Sendmail::error\n\$Mail::Sendmail::log: + $Mail::Sendmail::log\n";

    That should give you some idea of what happened. You could also check the logs on smtp.officedomain.com to see what it did with your email. It probably logged that it refused to relay, when you send to an external address.

      Thank you for your help. So the error I get is: "RCPT TO: error 550.5.7.1 Unable to relay for me@hotmail.com". I can email from my Outlook account to any outside address and I checked that the port is 25. Our IT guy says there are no authentication issues. Any last thoughts? Thanks!

        Assuming your mail server is Exchange, because you are using Outlook...

        Default policy in Exchange 2003 is to allow authenticated users to relay and Outlook authenticates, so from Outlook you can send to external mail domains. But default policy is to refuse to relay for unauthenticated connections.

        If this is the case, you can:

        1. Modify your script so it authenticates with the mail server.
        2. Change the server to allow the system your script runs on to relay without authentication.

        http://support.microsoft.com/kb/823019 tells you how to configure security and relaying restrictions on Exchange 2003, in case it is not familiar to your IT guy. If you are running some other version or server, google for allow smtp relay and the name and version of your software. It is a common issue, so it will be easy to find informaiton.

Re: Email beyond Domain
by sasdrtx (Friar) on Nov 19, 2008 at 02:47 UTC

    Usual stuff: Did you get an error message returned? How about in the server logs? Can you send mail outside your work domain with regular email clients?

    Psychic debugging is rarely efficient.

    sas
Re: Email beyond Domain
by Popcorn Dave (Abbot) on Nov 19, 2008 at 07:05 UTC
    One other thing to check is if your mail server is working on port 25 or some other port. Our server uses port 587 instead of port 25 for e-mail.


    To disagree, one doesn't have to be disagreeable - Barry Goldwater

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found