Webinoly is just the perfect tool for NGINX experts. Give it a try!
0 votes
2.8k views
by Talented

Lat time I had this problem you answered as follows -- https://webinoly.com/support/2706/cant-receive-email-sent-from-the-same-domain?show=2751#a2751

This time, all I have done with the email is I have installed Webinoly, and then issued the following command... (obfuscated before posting)

sudo webinoly webinoly -smtp=[email-smtp.eu-west-2.amazonaws.com,AKIA4K47875HJODXLDEGQXR,BCVhpp9fG34Dd8c37x587fz49mkx8AGm+2geI3dKkqQK9C,licencedbreeders.uk]

When no email was arriving I checked and I find that the postfix configuration looks like this again... 

mydestination = licencedbreeders.uk, localhost.uk, localhost

I can only assume that this was the problem last time. 

In setting up the SMTP server we (me and Webinoly) have also misconfigured postfix again.

Cristhian, can you check this please.

Terence.

by Talented
Once I removed my domain from the "mydestination=" list everything works as expected.
by Expert
Hi Terence,

Are you saying that you always get the domain name in "mydestination" after SMTP is configured with Webinoly?

Actually, yesterday I was using this command in a new server and I'm taking a look right now and everything is fine. The only thing that comes to my mind is that maybe the default postfix "main.cf" file is different depending on the cloud provider, sounds crazy but it's possible. Would be useful if you help me to debug this issue, check this file before and after Webinoly.
by Talented

Well I have done it twice and got the same result on both occasions. The first time it was on DigitalOcean and the second time was on Vultr.

I could do...

sudo webinoly -smtp -purge

check the config file/s, then configure the SMTP again, and see what happens?

Anything else you want me to check?

by Expert
Yes, you can do that!

Check the "mydestination" value before and after, please.
by Talented

Once I purged the SMTP it looked like this...

Then when I used the command similar to this...

sudo webinoly webinoly -smtp=[email-smtp.eu-west-2.amazonaws.com,AKIA4K47875HJODXLDEGQXR,BCVhpp9fG34Dd8c37x587fz49mkx8AGm+2geI3dKkqQK9C,licencedbreeders.u]

Then the main.cf file reverted to this...

So I had to remove my domain again so it would work.

It looks like the misconfiguration is coming from the SMTP setup line, as published in the docs.

 

by Expert

Ok. Now the thing is, why your domain is included in the default postfix file?

Let me explain some things to try to understand how to debug this issue:

  • Webinoly installs Postfix from the original source and we leave all the default values, we don't touch any file. Ok?
  • We save a copy of the "main.cf" file because we need it when people want to purge the SMTP, this way we can recover the original (default) configuration.
So, the question is, when is the domain added to this file?
Who is adding this domain in Postfix?
The only thing I can suggest is that you should do a clean installation in a new server and see this file after every step. Check inmediately after Webinoly stack is build and after every step after that.
I use it yesterday and everything is fine, so I'm pretty sure that is something particular of your configuration.
by Talented
Either that or I have misunderstood the meaning of "mainhost" ?
by Talented
I don't see how that resolves the issue.

The mainhost domain was not in the config until I set it up for SMTP; then when I purged the SMTP config it was removed. Then when I set it up for SMTP again it was back. What difference will setting up another server make?
by Expert

After you purged the SMTP you are seeing the original default configuration file that comes with Postfix. That file is saved (a copy) by Webinoly immediately after Postfix is installed on your server.

Why is your domain there?

That's the question!

by Expert
Just to clarify, Postfix is installed since the beginning when the complete stack is built, that's why is a surprise that your domain is included in the default file.

2 Answers

+1 vote
by Expert

I think I have found the cause of this issue.

Postfix will always use your local machine name (hostname) in the default configuration. Seems like at some point before installing Webinoly you are naming your server with the same name as your domain.

Please, confirm this, just run "hostname" in your terminal or see inside /etc/hostname.

by Talented
Yes that's correct. I wanted the VPS to be able to respond to a PTR request, but it seems that the Vultr doesn't support it, so it's a moot point now.
by Expert
Ok. I think this can be a very common case, so I will fix it in the next release (v1.11.0) to prevent this issue.
by Talented
Only one thing to say to that then... Cool beans!
by Talented
Just to let you know, I did a fresh install and even without using the command hostname=domain.tld, /etc/postfix/main.cf still ends up with myhostname = domain.tld as one of the entries, and then the mail won't flow, of course. But you know that already and have fixed it in 1.11 :-)
by Expert
Ok. Would be good if you can identify where this data is coming from. Think where you are entering the domain name during the server creation, or maybe if this name is attached to your Vultr account. I'm sure it can not appear only by magic.
by Talented
OK, so I went back through their "Deploy New Instance" process and the very last question asks for "Server Hostname & Label" so that's where its coming from. The hostname is being setup during the provisioning of the instance. I would imagine that's not a rare occurrence.
by Expert

Ok. At least now we are sure about the root cause of this issue.

What I think I will do to fix this issue is that I will always force mydestination = localhost. This must ensure that we never have unexpected values. Do you agree?

by Talented
Is there a possible future issue being created by ignoring the hostname setting? I don't know Postfix that well, but I am guessing the developers had something in their minds when they included hostname in their configuration, or is it Webinoly that ads it to the config file?
by Expert
Anything in Postfix "mydestination" variable is considered as local, so emails sent to any of these domains will be considered as local and will not be sent out, it remains in the local machine. That's why Postfix takes the hostname value by default as "local".
by Talented
OK then as a default, its probably better to force `mydestination = localhost` as long as it can be edited and overridden at a later stage, if needed.
by Talented
Some weird shit going on here dude :-)

Mail wasn't getting delivered from the website and I just noticed a `relay=local` in the mail log, so when I checked the main.cf file, sure enough the mydestination variable had my hostname in it again.

I am going to edit it out again but what can be putting it there/back?
by Expert

The bewitched server! devil

by Talented
edited by

Could it be the web host's install script again, running in maintenance mode. 

I'll ask them.

Maybe it's a late April 1st trick by Google angry

Question #1: Why does their install script do that ?

Question #2: What is running in maintenance mode on your system and reinstating the hostname variable in the mail config file, and why -- could it be part of their mail relay prevention measures ?

We'll no doubt find out something.

Possibly the truth even  laugh

by Talented

Our scripts do not change postfix.

Mike Wolfman
www.vultr.com

by Expert

Hi Terence,

Don't take me wrong, but I think you need to refine your debug method, the best way to report an issue is when you are able to reproduce it in a different, maybe new and fresh server.

Regards.

by Talented
No I don't take you wrong - I take you right!

I'll give it a try and see what happens.
by Talented

At Vultr I created a new instance named licencedbreeders.com

I set up Route 53 to point the licencedbreeders.com A record at 95.179.230.43

I checked the hostname -- it had been set to "licencedbreeders.com" by the Vultr install script

I checked for /etc/postfix/main.cf -- it didn't exist

Then I ran "sudo apt update && sudo apt upgrade"

Then I installed Webinoly with -- "wget -qO weby qrok.es/wy && sudo bash weby 3"

****************************************************************************
******    INSTALLATION HAS FINISHED SUCCESSFULLY     ******
****************************************************************************

I then checked the variables in the /etc/postfix/main.cf config file and they looked like this...

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = licencedbreeders.com

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

mydestination = , $myhostname, licencedbreeders.com, localhost.com, localhost

relayhost =

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

mailbox_size_limit = 0

recipient_delimiter = +

inet_interfaces = all

inet_protocols = all

So, right from the get-go, to send mail, the postfix/main.cf will have to be edited to remove the hostname/domain entry.

This is the third time this has happened so reproducable and its pretty conclusive, as far as I am concerned.  

If the hostname is defined in the server install script, the Webinoly install script is putting the hostname into the postfix/main.cf variables.

What other explanation could there be?

by Expert

That's exactly what I tried to explain in my answer:

https://webinoly.com/support/3056/same-postfix-problem-again?show=3111#a3111

"Postfix will always use your local machine name (hostname) in the default configuration."

by Talented
I guess I am just misunderstanding the primary role for using Postfix then, since that immediately means that in the default configuration, no mail will leave the server.
by Expert
That's only true if you are naming your hostname the same as your domain. The logic behind Postfix is simple, if an email is sent to your "home" domain, they don't need to leave the server, because they are already there at "home" (hostname).
by Talented
edited by
Brain dead.

What if Google had thought like that with gmail.com?

Oh well, different time and era I guess.

Or again, maybe, just a lack of understanding on my part.
0 votes
by Expert
This issue has been fixed in v1.11.0, released today.
by Talented
I know. Cool beans!
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...