Confusion about sendmail and /etc/hosts

I'm definitely a Linux newb so forgive me if this is a silly question ;)

My Linode is running Ubuntu 9.04.

A few months ago I installed sendmail and in order for it to work I modified my /etc/hosts to be like this:

****127.0.0.1 localhost.localdomain localhost [hostname]

127.0.0.1 [hostname].localdomain

[IP] [external hostname].members.linode.com****

I don't understand why I did that, I just read it somewhere and it seemed to work.

Then about a month ago I realized many of the emails coming from my primary domain were being marked as spam because the headers had:

Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])

So I edited the /etc/hosts again and modified the first line to be:

127.0.0.1 [domain] localhost.localdomain localhost [hostname]

(I added the domain name that the emails were coming from to the first line)

This seemed to help. The email headers looked better and I was getting a lot less bounces.

However, today I rebooted my server and that latest /etc/hosts change took down my domain so a browser just showed "It Works!" (I guess I hadn't restarted Apache since then).

So it seems I have two choices:

(1) Be able to send emails that actually arrive at their destination

(2) Have a website that's actually live

I'm hoping there's a 3rd option that lets me have both :)

6 Replies

It's certainly possible that there's something about Apache that I don't know, but I can't think of any way that change would lead to what you're describing. Is it possible there was some other change to the Apache config since the last reboot? You could find out for sure, of course, by switch /etc/hosts back, rebooting, and seeing what your Web page looks like.

Oh sorry, I didn't explain myself properly.

It definitely was that change because I've already removed my domain from the first line in /etc/hosts, restarted Apache and my site is up again.

I'm also totally confused why that would cause the "It Works!" problem :(

I'm having a similar problem.

Email sent by do-not-answer@mydomain.com are being rewrited in something like do-not-answer@yyxxx-x.members.linode.com

My hosts.conf is as follow:

127.0.0.1 localhost

xxx.xx.xxx.x    yyxxx-x.members.linode.com      mydomain.com

If I delete yyxxx-x.members.linode.com in my hosts.conf, then when trying to reach mydomain.com with a broswer, I obtain "It works". With www.mydomain.com, it still work.

The Apache virtual host in charge of this domain looks like that:

  <virtualhost *:80="">ServerName mydomain.com
     ServerAlias www.mydomain.com</virtualhost> 

Any ideas ?

Edit /etc/hosts

127.0.0.1 localhost.localdomain localhost

10.10.10.10 server.example.com server

Where:

10.10.10.10 is replaced by the real IP address assigned to your Linode.

server is replaced by the name of your host in /etc/hostname (can be anything you want)

example.com is replaced by your real domain name.

This is what I have in my /etc/hosts. Start with that and move forward.

@vincemd:

I'm having a similar problem.

Any ideas ?

Edit /etc/apache2/sites-available/default

Default virtual host - replaces main server

Setup other virtual hosts pointing to the users home directory

Edit /etc/apache2/sites-available/example.net

ServerName example.net

ServerAlias www.example.net

DocumentRoot "/home/girlie/public_html"

ScriptAlias /cgi-bin/ /home/girlie/cgi-bin/

Replace domains and users to match yours.

Then run a2ensite with the domain file name.

thank you, problem solved :)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct