How to configure exim4 to send & receive email on a VPS using my own domain name? : <p>I just bought a new "public cloud" to put my new website on it.</p>

<p>This public cloud is in "advanced zone", which means that every instance I deploy is in a NAT network with private IP (10.1.1.x), and there is a firewall in front of the global network to control IN and OUT ports.</p>

<p>I have deployed two instances with Debian 8, one for webserver &amp; the other one for the database.
  I have my own domain name (let's say "mydomain.com"), and I want my website to be able to send email using this domain name (FROM would be "no-reply@mydomain.com") and I would like to receive emails sent by users of the website (TO contact@mydomain.com) using a Thunderbird or Outlook for example.</p>

<p>Exim4 was already installed on the webserver (installed by default in Debian 8), I used <code>dpkg-reconfigure exim4-config</code> to reconfigure it. Here is the content of my different files.</p>

<p>/etc/exim4/update-exim4.conf.conf</p>

<pre><code>dc_eximconfig_configtype='internet'
dc_other_hostnames='contact.mydomain.com'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
</code></pre>

<p>/etc/hosts :</p>

<pre><code>ROUTER_IP  mydomain.com    contact
</code></pre>

<p>/etc/hostname :</p>

<pre><code>contact
</code></pre>

<p>/etc/email-addresses :</p>

<pre><code>contact@mydomain.com
</code></pre>

<p>When I type <code>hostname</code> : contact<br>
When I type <code>hostname -d</code> : com<br>
When I type <code>hostname -f</code> : mydomain.com</p>

<p>In my DNS I created a zone with SPF type to avoid spam. Here it is :</p>

<pre><code>TTL = 600 / Target = "v=spf1 a mx ptr ~all"
</code></pre>

<p>I tried to send an email using this command :</p>

<pre><code>echo "This is a test." | mail -s Testing myownaddress@gmail.com
</code></pre>

<p>When I'm sending an email to gmail, I receive an email from <code>root (root@mydomain.com)</code> and not <code>contact@mydomain.com</code></p>

<p>When I'm sending an email to my own personnal address, I have an error in exim4 mainlog <code>/var/log/exim4/mainlog</code> :</p>

<pre><code>SMTP error from remote mail server after RCPT TO:&lt;johnny@myserver.com&gt;: host mail.myserver.com [37.xx.xx.Xx]: 504 5.5.2 &lt;contact&gt;: Helo command rejected: need fully-qualified hostname
</code></pre>

<p>I don't understand what I'm doing wrong.  Do you have any idea on this please ?</p>

<p>Thanks in advance !<br>
Regards,<br>
Julien Q.</p>
