Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

OT - Sending Email on Windows

by tanger (Scribe)
on Apr 22, 2005 at 06:36 UTC ( [id://450287]=perlquestion: print w/replies, xml ) Need Help??

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

hi,

k i had enough with this. i've spent the last 3 hours or so trying to get my perl script to send e-mail. i tried using several of the known modules such as Mail::Mailer, Mail::Sendmail, and NET::SMTP.

I know that on windows you need to connect to a SMTP server, but I have no clue what my SMTP address is. I tried going to www.dnsreport.com to type in my domain name and copied and paste the mail address, but stil NO luck.

I just recently read a lot about SMTP. I know that this problem I have (550 5.7.1 Unable to relay ) is due to a connection failure to the SMTP. I tried using the Relay config options under IIS for windows but still no luck.

I guess I'm stuck, and I might just use that "blat.exe" program. OR please say that doens't require a SMTP address too?
ty tanger

Replies are listed 'Best First'.
Re: OT - Sending Email on Windows
by Jaap (Curate) on Apr 22, 2005 at 06:54 UTC
    So you have a windows box. Do you run ANY program on it that can send mail (Outlook (Express), Thunderbird...)? If so, check that program for the outgoing mail server. This is the SMTP server you have to use to send mail.

    If not, ask your ISP or Host what the correct SMTP server is. Only they know.
Re: OT - Sending Email on Windows
by gellyfish (Monsignor) on Apr 22, 2005 at 08:14 UTC

    Yes Blat does need to know the address of an SMTP server to work.

    Your best best is to get the local IIS to act as an SMTP relay - the error you are getting is simply an indication of its unwillingness to relay as you have got the configuration incorrect. I am assuming here that you are using Windows 2000 and you have an administrative account (the instructions are similar for XP).

    The default configuration of the SMTP service on Windows 2000 SP2 and better is not to relay at all so you are going to have to allow connections and relaying from the localhost only:

    • First open internet services manager in the administrative tools menu.
    • Expand the local server in the tree view on the left and righ click on "default SMTP virtual server" and select "Properties"
    • Select the "Access" tab. Firstly click on the Authentication button and check that "Anonymous access" is checked.
    • Back on the access property page click the "Connection control" button". Select the "only the list below" radio button and click the "Add" button, in the "Computer" page that appears check "Group" of computers: put "127.0.0.0" in subnet address and "255.255.255.0" in Subnet mask. Press "Ok". Press "Ok" to leave the connectin dialogue.
    • Click the "Relay restrictions" button. In the "Relay restrictions" dialogue check "only the list below" is checked, then press add. In the "Computer" page that appears check "Group" of computers: put "127.0.0.0" in subnet address and "255.255.255.0" in Subnet mask. Press "Ok". Press okay to leave the "Relay restrictions" dialogue. Press OKay to leave the properties page.
    • Stop and restart the SMTP service by using the buttons on the right of the toolbar.
    • Et Voila!

      /J\

      And for those who aren't familiar with localhost -- you'll have to specifically connect to the loopback address for this to work. If your outgoing IP address is 10.0.0.1, you'd not be able to pass mail if you connect to that e-mail address.

      You would need to set your SMTP server in whatever other program to 127.0.0.1

Re: OT - Sending Email on Windows
by tcf03 (Deacon) on Apr 22, 2005 at 08:53 UTC
    any solution you use is going to require an SMTP server. I suggest ou call your ISP.

    Ted
      I'm on windoze also. I use Mail::Sendmail, but you need to know your smtp server! Edit the module and make the changes to reflect your smtp server and then edit\run this code to send an e-mail
      #print "sending email"; my $Msg = "my first email"; my %mail = ( To => 'YOU@YOUREMAIL.com', Cc => 'SOMEONE@SOMEWHERE.com', From => 'HOST@SOMEWHERE.com', Subject => "Message", Message => "$Msg \n"); sendmail(%mail) or die $Mail::Sendmail::error;
        Hi,!

        thanks for the replies everyone.

        I just followed gellyfish 's detailed instructions on configuring my IIS to allow relay connections for my SMTP at localhost and I finally got it to work!

        As of now, all I can hope is that I'm not the only one who had this problem with sending e-mail on Windows. Hopefully anyone who was in my situation --(Has adminstrative access to there Windows server and trying to allow your SMPT to relay so your perl script can work!) --then they can use this thread to solve their problem.

        It took so long sitting last night w/out accomplishing anything only because I took the time to try to get all three modules working to send e-mail, read all three e-mail sending module doc's, smpt related info, and basic IIS smpt config that in the long run didn't help much but give me a bit more knowledge.

        Thanks tanger
Re: OT - Sending Email on Windows
by RolandGunslinger (Curate) on Apr 22, 2005 at 16:55 UTC
    This is what I used to send pages to my text pager from Windows.
    #!perl use strict; use warnings; use Net::SMTP; sub send_page { my ($host, $address, $subject, $message) = @_; my $smtp = Net::SMTP->new($host); $smtp->mail("sendlog.pl\@localhost"); $smtp->to("$address"); $smtp->data(); $smtp->datasend("To: $address\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("$message"); $smtp->dataend(); $smtp->quit; } 1;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-23 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found