[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1701
  • Last Modified:

sendmail sends the messages as localhost and ISP refuses them

I have a Linux server I installed that is only used by myself
I have fetchmail running fine
Procmail rules work fine as well
I have one rule to forward mail sent to support@company.com to user@yahoo.com
That doesnt work.
To test it I issue the command on prompt:
mail -s Test user@yahoo.com < message.txt

the message is bounced back from the ISP

That is I think because the message apears to be send from localhost.local domain, IP 127.0.0.1 and the ISP refuses it

see bellow part of the message

<...>
Return-Path: <MAILER-DAEMON@net4b.pt>
Received: from localhost (localhost)
      by localhost.localdomain (8.12.11/8.12.11) id iA5KMlIi008461;
<...>
From: Mail Delivery Subsystem <MAILER-DAEMON@net4b.pt>
Message-Id: <200411052022.iA5KMlIi008461@localhost.localdomain>
To: <root@localhost.localdomain>
<...>
The original message was received at Fri, 5 Nov 2004 20:22:43 GMT
from STRIDER [127.0.0.1]

   ----- The following addresses had permanent fatal errors -----
<blucaster@yahoo.com>
    (reason: 554 mailfrom without country or top level domain is administratively denied)

   ----- Transcript of session follows -----
.... while talking to smtp.net4b.pt.:
>>> MAIL From:<root@localhost.localdomain> SIZE=339
<<< 554 mailfrom without country or top level domain is administratively denied
554 5.0.0 Service unavailable
<...>
Action: failed


I dont want to set up a DNS server.
Only thing I want is to set up the linux server to be able to send mail using the same smtp server that works just fine if I do it from windows

If on the windows mail client I set the SMTP server to smtp.net4b.pt the mail is sent ok, and the recipients see it coming from roger@company.com

I only want to do the same from linux prompt
0
ROGERPORT
Asked:
ROGERPORT
  • 3
  • 3
  • 3
  • +1
3 Solutions
 
owensleftfootCommented:
You need to set your hostname to a valid one - it doesnt matter what. As long as it resolves as a valid hostname your mail will be accepted.
0
 
wesly_chenCommented:
Hi,

  Is your linux server's hostname/IP in your DNS server?
  What's the content of your /etc/hosts?

Wesly
0
 
owensleftfootCommented:
By that I mean a hostname with a proper dns record. I have a machine in work which has the hostname owensleftfoot@mycompany.co.uk.  mycompany.co.uk is a valid registered domainname although it has nothing associated with it - the real domainname is mycompany.com. The only problem with this is that "Apparently From user@mycompany.co.uk" will show up in the headers.
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
jlevieCommented:
The usual solution here is to set the hostname of your machine to be what a reverse lookup of the IP you get from your ISP resolves to. In addition to setting the hostname (in /etc/sysconfig/network or RedHat or similar) you need a record in /etc/hosts, something along the lines of:

127.0,0.1     localhost.localdomain localhost
123.4.5.6     node-name.my-isp.tld node-name
0
 
ROGERPORTAuthor Commented:
I thank you for you help, and done some tries with your sugestion, but cant put it to work.

Can you please tell me exactly what should I change based on the info bellow

/etc/sysconfig/network
NETWORKING=YES
HOSTNAME=STRIDER

/etc/hosts
127.0.0.1 strider localhost.localdomain localhost

my ISP smtp server
SMTP.NET4B.PT

My Company domain that is hosted on the same ISP
www.glance.pt
0
 
wesly_chenCommented:
/etc/hosts
-------
127.0.0.1 localhost.localdomain localhost
<strider's IP>  strider.company.com  strider
------

/etc/sysconfig/network
-------
NETWORKING=YES
HOSTNAME=STRIDER
DOMAIN=company.com
---

Wesly
0
 
ROGERPORTAuthor Commented:
OK. I can send mail now if the address in TO: does not include glance.pt
I still cant send mail to someone with email mary@glance.pt that picks his mail directly from the isp from home

mail -s TEST mary@yahoo.com -> RECEIVES MAIL OK
mail -s TEST mary@glance.pt -> DOES NOT RECEIVE MAIL

I list bellow the actual config files

Mind that strider is a server on a local network with IP 192.168.0.1
Since this IP will not resolve I used IP 195.245.176.3 that is the IP of www.glance.pt that is hosted on ISP

/etc/hosts
-------
127.0.0.1 localhost.localdomain localhost
195.245.176.3 glance.pt  strider
------

/etc/sysconfig/network
-------
NETWORKING=YES
HOSTNAME=STRIDER
DOMAIN=glance.pt
---
0
 
wesly_chenCommented:
> /etc/hosts
> -------
> 127.0.0.1 localhost.localdomain localhost
> 195.245.176.3 glance.pt  strider   <===== ? ?
> ------
Should it be
----
192.168.0.1  strider.glance.pt strider
195.245.176.3 www.glance.pt
----

Wesly
0
 
jlevieCommented:
> Mind that strider is a server on a local network with IP 192.168.0.1

In which case your hosts file should contain:

127.0.0.1 localhost.localdomain localhost
192.168.0.1 strider.glance.pt  strider

and /etc/sysconfig/network should contain:

NETWORKING=YES
HOSTNAME=strider.glance.pt

And since this machine is in the glance.pt domain you can't send mail to mary@glance.pt since that looks like a local account to Sendmail (the machine is in the glance.pt domain). To be able to send mail to a user in this domain whose account is on your ISP's mail server you need to configure an LUSER_RELAY in sendmail.mc pointing to the MTA for the domain, like:

define(`LUSER_RELAY'', `smtp.net4b.pt')dnl
0
 
ROGERPORTAuthor Commented:
OK. Everything is working now

This are the changes I had to do

/etc/hosts
-------
127.0.0.1 localhost.localdomain localhost
192.168.0.1 glance.pt  strider
------

/etc/sysconfig/network
-------
NETWORKING=YES
HOSTNAME=glance.pt
---

define(`LUSER_RELAY'', `smtp.net4b.pt')dnl

define(`SMART_HOST',`smtp.net4b.pt')dnl

If I put strider.glance.pt on /etc/hosts and /etc/sysconfig/network the mails were refused because the MX record doest exist
I am sure if you have realised that the machine hosting the domain www.glance.pt is on my ISP and has an IP compleatly diferent from the IP of my server (strider) which has only a local IP 192.168.0.1 and connects to the internet by dial-up (doesnt have  fixed IP).

Anyway it's working now thanks to your help. I am spliting the points what is something that always makes me feel bad because I want to be fair. Will do my best.
0
 
jlevieCommented:
That's really an incorrect configuration. By setting the hostname to glance.pt you are claiming that the machine is the domain rather than a node within the domain. The MX record for the domain should not be a factor unless you intend this box to be the mail server for the domain, which I don't think is the case here.

I suspect that your problems when the hostname was strider.glance.pt was that you didn't have the correct data in /etc/mail/local-host-names. It should contain:

localhost.localdomain
localdomain
strider.glance.pt
glance.pt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now