Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Bad hostname 'mailhost'

by talexb (Canon)
on Mar 26, 2002 at 16:58 UTC ( #154441=perlquestion: print w/replies, xml ) Need Help??
talexb has asked for the wisdom of the Perl Monks concerning the following question:

I have written a script that will send out a weekly updated via E-Mail using Mail::Internet; it works fine except that I get the following output:
Net::SMTP: Bad hostname 'mailhost' at blib/lib/Mail/ (autos +plit into blib/lib/auto/Mail/Internet/ line 577 Net::SMTP: Bad hostname 'mailhost' at blib/lib/Mail/ (autosplit + into blib/lib/auto/Mail/Util/ line 176
It appears that this is a warning only -- the E-Mail arrives properly, but I would like to see if there is a way to resolve the problem, since my preferred operation is without warnings.

I have search on PM and on Google: I tried substituting 'localhost' in the my $Message = Mail::Internet->new(); call, and that got rid of the warning from Net::SMTP but instead I got the message Can't use string ("localhost") as a symbol ref while "strict refs" in use at /usr/lib/perl5/Mail/ line 68. --t. alex

"Here's the chocolates, and here's the flowers. Now how 'bout it, widder hen, will ya marry me?" --Foghorn Leghorn

Replies are listed 'Best First'.
Re: Bad hostname 'mailhost'
by shotgunefx (Parson) on Mar 26, 2002 at 17:27 UTC
    I'm using an older version 1.33 but it looks like that if no host is passed it checks mailhost and then localhost. So mailhost is probably failing but localhost succeeds.


    "To be civilized is to deny one's nature."
      I have version 1.32 (I'm stuck with that version for now) -- so is this a warning that I can safely ignore?

      I don't mind seeing a warning as long as I know it's relatively benign.

      --t. alex

      "Here's the chocolates, and here's the flowers. Now how 'bout it, widder hen, will ya marry me?" --Foghorn Leghorn

        If it's working then I'd say yes. What I'd do is open up the .pm file in vi/emacs/pico and look at the line in question. If you see something like the following, it just means that it's trying mailhost first and it's failing.
        unless(defined($host)) { local $SIG{__DIE__}; my @hosts = qw(mailhost localhost); unshift(@hosts, split(/:/, $ENV{SMTPHOSTS})) if(defined $ENV{S +MTPHOSTS}); foreach $host (@hosts) { $smtp = eval { Net::SMTP->new($host, @hello) }; last if(defined $smtp); } }
        If you are the sysadmin, you could just remove the mailhost out of the qw() or set up the alias for mailhost in /etc/hosts. Another way to supress the warning would be to specify loclhost in $ENV{SMTPHOSTS}.


        "To be civilized is to deny one's nature."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://154441]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2017-11-24 02:51 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (343 votes). Check out past polls.