Perl/Mail Suggestion....

Discussion in 'Perl Misc' started by amerar@iwc.net, Nov 28, 2006.

  1. Guest

    Hi all,

    I've just built myself a new server and installed Linux. I currently
    have a mailserver rnning Red Hat 9.0 and I'm using Postifx.

    My existing server runs just fine. I want to bring my new server
    online to test the mail portion without taking down my current server.

    I have set up Squirrelmail and that seems to deliver mail just fine.
    However, when I try and run a Perl script which uses the Net::SMTP
    module, I receive this error:

    "Can't call method "mail" on an undefined value at
    /prod/scripts/send.pl line 208."

    Here is a clip of my code:

    $smtp = Net::SMTP->new("nytelife");
    $smtp->mail("mail.chicagorsvp.com");
    $smtp->to($email);
    $smtp->data();

    That is the code that currently runs on the Red Hat 9.0 existing
    server. I am wondering if this is a problem due to hostnames or
    something. I'm just lost and have no idea where to look.......

    Can anyone help or offer a suggestion?

    Thanks!
    , Nov 28, 2006
    #1
    1. Advertising

  2. Guest

    wrote:
    > Hi all,
    >
    > I've just built myself a new server and installed Linux. I currently
    > have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    >
    > My existing server runs just fine. I want to bring my new server
    > online to test the mail portion without taking down my current server.
    >
    > I have set up Squirrelmail and that seems to deliver mail just fine.
    > However, when I try and run a Perl script which uses the Net::SMTP
    > module, I receive this error:
    >
    > "Can't call method "mail" on an undefined value at
    > /prod/scripts/send.pl line 208."
    >
    > Here is a clip of my code:
    >
    > $smtp = Net::SMTP->new("nytelife");
    > $smtp->mail("mail.chicagorsvp.com");
    > $smtp->to($email);
    > $smtp->data();
    >
    > That is the code that currently runs on the Red Hat 9.0 existing
    > server. I am wondering if this is a problem due to hostnames or
    > something. I'm just lost and have no idea where to look.......
    >
    > Can anyone help or offer a suggestion?
    >
    > Thanks!


    I have another question:

    In line #2: $smtp->mail("mail.chicagorsvp.com");

    Where is that mail server definition defined? I'll need to change the
    name on the new server so there is no conflict......

    Thanks!
    , Nov 28, 2006
    #2
    1. Advertising

  3. Guest

    Sharif Islam wrote:
    > wrote:
    > > Hi all,
    > >
    > > I've just built myself a new server and installed Linux. I currently
    > > have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    > >
    > > My existing server runs just fine. I want to bring my new server
    > > online to test the mail portion without taking down my current server.
    > >
    > > I have set up Squirrelmail and that seems to deliver mail just fine.
    > > However, when I try and run a Perl script which uses the Net::SMTP
    > > module, I receive this error:
    > >
    > > "Can't call method "mail" on an undefined value at
    > > /prod/scripts/send.pl line 208."
    > >
    > > Here is a clip of my code:
    > >
    > > $smtp = Net::SMTP->new("nytelife");
    > > $smtp->mail("mail.chicagorsvp.com");
    > > $smtp->to($email);
    > > $smtp->data();

    >
    > can you make sure you are able to connect to the smtp server?
    > Try this:
    >
    > $smtp = Net::SMTP->new("nytelife"); # connect to an SMTP server
    > if (defined $smtp)
    > {
    >
    > $smtp->mail("mail.chicagorsvp.com");
    > $smtp->to($email);
    > $smtp->data();
    > }
    > else {
    > print "Cannot to connect to nytelife";
    > exit;
    > }
    >
    > --sharif


    Hmm....says it cannot connect, even though Postfix IS running and I can
    send email internally.......

    Any thoughts?

    I've shutdown postfix on my other server, and I've changed my
    forwarding on my router to forward posts 25 & 113 to the new
    machine........
    , Nov 29, 2006
    #3
  4. Guest

    Sharif Islam wrote:
    > wrote:
    > > Hi all,
    > >
    > > I've just built myself a new server and installed Linux. I currently
    > > have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    > >
    > > My existing server runs just fine. I want to bring my new server
    > > online to test the mail portion without taking down my current server.
    > >
    > > I have set up Squirrelmail and that seems to deliver mail just fine.
    > > However, when I try and run a Perl script which uses the Net::SMTP
    > > module, I receive this error:
    > >
    > > "Can't call method "mail" on an undefined value at
    > > /prod/scripts/send.pl line 208."
    > >
    > > Here is a clip of my code:
    > >
    > > $smtp = Net::SMTP->new("nytelife");
    > > $smtp->mail("mail.chicagorsvp.com");
    > > $smtp->to($email);
    > > $smtp->data();

    >
    > can you make sure you are able to connect to the smtp server?
    > Try this:
    >
    > $smtp = Net::SMTP->new("nytelife"); # connect to an SMTP server
    > if (defined $smtp)
    > {
    >
    > $smtp->mail("mail.chicagorsvp.com");
    > $smtp->to($email);
    > $smtp->data();
    > }
    > else {
    > print "Cannot to connect to nytelife";
    > exit;
    > }
    >
    > --sharif


    I meant to say ports 25 & 110.......
    , Nov 29, 2006
    #4
  5. Ric Guest

    schrieb:
    > Sharif Islam wrote:
    >> wrote:
    >>> Hi all,
    >>>
    >>> I've just built myself a new server and installed Linux. I currently
    >>> have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    >>>
    >>> My existing server runs just fine. I want to bring my new server
    >>> online to test the mail portion without taking down my current server.
    >>>
    >>> I have set up Squirrelmail and that seems to deliver mail just fine.
    >>> However, when I try and run a Perl script which uses the Net::SMTP
    >>> module, I receive this error:
    >>>
    >>> "Can't call method "mail" on an undefined value at
    >>> /prod/scripts/send.pl line 208."
    >>>
    >>> Here is a clip of my code:
    >>>
    >>> $smtp = Net::SMTP->new("nytelife");
    >>> $smtp->mail("mail.chicagorsvp.com");
    >>> $smtp->to($email);
    >>> $smtp->data();

    >> can you make sure you are able to connect to the smtp server?
    >> Try this:
    >>
    >> $smtp = Net::SMTP->new("nytelife"); # connect to an SMTP server
    >> if (defined $smtp)
    >> {
    >>
    >> $smtp->mail("mail.chicagorsvp.com");
    >> $smtp->to($email);
    >> $smtp->data();
    >> }
    >> else {
    >> print "Cannot to connect to nytelife";
    >> exit;
    >> }
    >>
    >> --sharif

    >
    > Hmm....says it cannot connect, even though Postfix IS running and I can
    > send email internally.......
    >
    > Any thoughts?
    >
    > I've shutdown postfix on my other server, and I've changed my
    > forwarding on my router to forward posts 25 & 113 to the new

    110 is only for pop and postfix does no pop:)
    > machine........
    >


    so your mailservers hostname is: mail.chicagorsvp.com ?

    If it is you should be able to telnet to it:

    telnet mail.chicagorsvp.com 25

    You should see the postfix response message. Now you can type:

    EHLO chicagorsvp.com

    You should see response ok. Type:

    MAIL FROM: youremailadress

    You should see ok. Type

    RCPT TO: emailadress

    You should see ok. Type

    DATA

    Mailserver responds: enter mail. Type your mail

    dfssadfa

    then newline . exit

    depending ony what kind of mailadresses you used and how you configured
    the mailserver may reject your message. If you don't even see the
    initial postfix responce, then try with the ip of your machine.
    Ric, Nov 29, 2006
    #5
  6. Guest

    Ric wrote:
    > schrieb:
    > > Sharif Islam wrote:
    > >> wrote:
    > >>> Hi all,
    > >>>
    > >>> I've just built myself a new server and installed Linux. I currently
    > >>> have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    > >>>
    > >>> My existing server runs just fine. I want to bring my new server
    > >>> online to test the mail portion without taking down my current server.
    > >>>
    > >>> I have set up Squirrelmail and that seems to deliver mail just fine.
    > >>> However, when I try and run a Perl script which uses the Net::SMTP
    > >>> module, I receive this error:
    > >>>
    > >>> "Can't call method "mail" on an undefined value at
    > >>> /prod/scripts/send.pl line 208."
    > >>>
    > >>> Here is a clip of my code:
    > >>>
    > >>> $smtp = Net::SMTP->new("nytelife");
    > >>> $smtp->mail("mail.chicagorsvp.com");
    > >>> $smtp->to($email);
    > >>> $smtp->data();
    > >> can you make sure you are able to connect to the smtp server?
    > >> Try this:
    > >>
    > >> $smtp = Net::SMTP->new("nytelife"); # connect to an SMTP server
    > >> if (defined $smtp)
    > >> {
    > >>
    > >> $smtp->mail("mail.chicagorsvp.com");
    > >> $smtp->to($email);
    > >> $smtp->data();
    > >> }
    > >> else {
    > >> print "Cannot to connect to nytelife";
    > >> exit;
    > >> }
    > >>
    > >> --sharif

    > >
    > > Hmm....says it cannot connect, even though Postfix IS running and I can
    > > send email internally.......
    > >
    > > Any thoughts?
    > >
    > > I've shutdown postfix on my other server, and I've changed my
    > > forwarding on my router to forward posts 25 & 113 to the new

    > 110 is only for pop and postfix does no pop:)
    > > machine........
    > >

    >
    > so your mailservers hostname is: mail.chicagorsvp.com ?
    >
    > If it is you should be able to telnet to it:
    >
    > telnet mail.chicagorsvp.com 25
    >
    > You should see the postfix response message. Now you can type:
    >
    > EHLO chicagorsvp.com
    >
    > You should see response ok. Type:
    >
    > MAIL FROM: youremailadress
    >
    > You should see ok. Type
    >
    > RCPT TO: emailadress
    >
    > You should see ok. Type
    >
    > DATA
    >
    > Mailserver responds: enter mail. Type your mail
    >
    > dfssadfa
    >
    > then newline . exit
    >
    > depending ony what kind of mailadresses you used and how you configured
    > the mailserver may reject your message. If you don't even see the
    > initial postfix responce, then try with the ip of your machine.


    Hmm...tried your suggestion, here is the output:

    [root@nytelife scripts]# telnet mail.chicagorsvp.com 25
    Trying 206.126.253.242...
    telnet: connect to address 206.126.253.242: Connection refused

    And, I have IPTABLES running, but I've enabled ports 110 & 25:

    ACCEPT tcp -- anywhere anywhere state NEW
    tcp dpt:smtp
    ACCEPT tcp -- anywhere anywhere state NEW
    tcp dpt:pop3

    Any suggestions? This is weird as I copied config files from a working
    server.....
    , Nov 29, 2006
    #6
  7. Guest

    Ric wrote:
    > schrieb:
    > > Sharif Islam wrote:
    > >> wrote:
    > >>> Hi all,
    > >>>
    > >>> I've just built myself a new server and installed Linux. I currently
    > >>> have a mailserver rnning Red Hat 9.0 and I'm using Postifx.
    > >>>
    > >>> My existing server runs just fine. I want to bring my new server
    > >>> online to test the mail portion without taking down my current server.
    > >>>
    > >>> I have set up Squirrelmail and that seems to deliver mail just fine.
    > >>> However, when I try and run a Perl script which uses the Net::SMTP
    > >>> module, I receive this error:
    > >>>
    > >>> "Can't call method "mail" on an undefined value at
    > >>> /prod/scripts/send.pl line 208."
    > >>>
    > >>> Here is a clip of my code:
    > >>>
    > >>> $smtp = Net::SMTP->new("nytelife");
    > >>> $smtp->mail("mail.chicagorsvp.com");
    > >>> $smtp->to($email);
    > >>> $smtp->data();
    > >> can you make sure you are able to connect to the smtp server?
    > >> Try this:
    > >>
    > >> $smtp = Net::SMTP->new("nytelife"); # connect to an SMTP server
    > >> if (defined $smtp)
    > >> {
    > >>
    > >> $smtp->mail("mail.chicagorsvp.com");
    > >> $smtp->to($email);
    > >> $smtp->data();
    > >> }
    > >> else {
    > >> print "Cannot to connect to nytelife";
    > >> exit;
    > >> }
    > >>
    > >> --sharif

    > >
    > > Hmm....says it cannot connect, even though Postfix IS running and I can
    > > send email internally.......
    > >
    > > Any thoughts?
    > >
    > > I've shutdown postfix on my other server, and I've changed my
    > > forwarding on my router to forward posts 25 & 113 to the new

    > 110 is only for pop and postfix does no pop:)
    > > machine........
    > >

    >
    > so your mailservers hostname is: mail.chicagorsvp.com ?
    >
    > If it is you should be able to telnet to it:
    >
    > telnet mail.chicagorsvp.com 25
    >
    > You should see the postfix response message. Now you can type:
    >
    > EHLO chicagorsvp.com
    >
    > You should see response ok. Type:
    >
    > MAIL FROM: youremailadress
    >
    > You should see ok. Type
    >
    > RCPT TO: emailadress
    >
    > You should see ok. Type
    >
    > DATA
    >
    > Mailserver responds: enter mail. Type your mail
    >
    > dfssadfa
    >
    > then newline . exit
    >
    > depending ony what kind of mailadresses you used and how you configured
    > the mailserver may reject your message. If you don't even see the
    > initial postfix responce, then try with the ip of your machine.


    Also, I ran netstat. I'm not sure if this is correct or not, so maybe
    someone can look and tell me of the Port 25 entry is correct?


    [root@nytelife scripts]# netstat -atn |grep LISTEN
    tcp 0 0 0.0.0.0:3306 0.0.0.0:*
    LISTEN
    tcp 0 0 0.0.0.0:907 0.0.0.0:*
    LISTEN
    tcp 0 0 127.0.0.1:783 0.0.0.0:*
    LISTEN
    tcp 0 0 0.0.0.0:111 0.0.0.0:*
    LISTEN
    tcp 0 0 127.0.0.1:631 0.0.0.0:*
    LISTEN
    tcp 0 0 127.0.0.1:25 0.0.0.0:*
    LISTEN
    tcp 0 0 :::993 :::*
    LISTEN
    tcp 0 0 :::995 :::*
    LISTEN
    tcp 0 0 :::110 :::*
    LISTEN
    tcp 0 0 :::143 :::*
    LISTEN
    tcp 0 0 :::80 :::*
    LISTEN
    tcp 0 0 :::443 :::*
    LISTEN
    , Nov 29, 2006
    #7
  8. Ric Guest


    >
    > Hmm...tried your suggestion, here is the output:
    >
    > [root@nytelife scripts]# telnet mail.chicagorsvp.com 25
    > Trying 206.126.253.242...
    > telnet: connect to address 206.126.253.242: Connection refused


    and 206.126.253.242 is the ip of your new mailserver?
    >
    > And, I have IPTABLES running, but I've enabled ports 110 & 25:
    >
    > ACCEPT tcp -- anywhere anywhere state NEW
    > tcp dpt:smtp
    > ACCEPT tcp -- anywhere anywhere state NEW
    > tcp dpt:pop3
    >
    > Any suggestions? This is weird as I copied config files from a working
    > server.....


    well that may be the problem, depending on what you copied and depending
    on your network setup:)
    >


    Without knowing your whole network setup this is difficult to check if
    everything is okay, you may need forwarding rules etc.

    Just run the telnet commands I told you earlier on your new mailserver
    (mail.chicagorsvp.com)

    on that machine in a konsole:

    telnet localhost 25

    If that works you know this machine is okay and you have a
    network/firewal problem.

    But this is definitely not the appropriate mailinglist for your problem.
    Ric, Nov 29, 2006
    #8
  9. Guest

    Ric wrote:
    > >
    > > Hmm...tried your suggestion, here is the output:
    > >
    > > [root@nytelife scripts]# telnet mail.chicagorsvp.com 25
    > > Trying 206.126.253.242...
    > > telnet: connect to address 206.126.253.242: Connection refused

    >
    > and 206.126.253.242 is the ip of your new mailserver?
    > >
    > > And, I have IPTABLES running, but I've enabled ports 110 & 25:
    > >
    > > ACCEPT tcp -- anywhere anywhere state NEW
    > > tcp dpt:smtp
    > > ACCEPT tcp -- anywhere anywhere state NEW
    > > tcp dpt:pop3
    > >
    > > Any suggestions? This is weird as I copied config files from a working
    > > server.....

    >
    > well that may be the problem, depending on what you copied and depending
    > on your network setup:)
    > >

    >
    > Without knowing your whole network setup this is difficult to check if
    > everything is okay, you may need forwarding rules etc.
    >
    > Just run the telnet commands I told you earlier on your new mailserver
    > (mail.chicagorsvp.com)
    >
    > on that machine in a konsole:
    >
    > telnet localhost 25
    >
    > If that works you know this machine is okay and you have a
    > network/firewal problem.
    >
    > But this is definitely not the appropriate mailinglist for your problem.


    Well, problem turned out to be that port 25 was open to 127.0.0.1 only,
    as you can see above. Once I changed the port to be open on all
    interfaces, it worked. It still does not explain the 3 colons :)::) on
    the other ports......that's kind of weird......
    , Nov 29, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. scadav
    Replies:
    2
    Views:
    443
    scadav
    Jul 3, 2004
  2. Curt_C [MVP]
    Replies:
    5
    Views:
    364
    Karim
    May 19, 2004
  3. Guest
    Replies:
    3
    Views:
    105
    David K. Wall
    Oct 14, 2003
  4. Vijayaraghavan Kalyanapasupathy

    Suggestion: Use EPIC as a perl editor/debugger

    Vijayaraghavan Kalyanapasupathy, Oct 20, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    116
    A. Sinan Unur
    Oct 20, 2004
  5. Replies:
    3
    Views:
    114
    Thrill5
    Aug 29, 2006
Loading...

Share This Page