0

I have multiple websites running on my server: domain1.com and domain2.com

The problem is now that when I sent an email via ASP.NET from domain2.com, that in this email source I see (notice domain1):

Received: from mail.domain1.com (h2134215.myisp.com. [81.112.2.12)
Received: from h2134215 ([81.112.2.12]) by domain1.com with MailEnable ESMTPA; Sat, 21 Jun 2021 22:17:29 +0200
Message-ID: <D9221D4FF6F74EC3877CC9368DDDAB94.MAI@domain1.com>

I'm using Mail Enable to send emails via ASP.NET like so:

Dim mailObj As New SmtpClient
mailObj.Host = localhost

I also tried:

Dim mailObj As New SmtpClient
mailObj.Host = "smtp.domain2.com"

Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@domain2.com", "mypassword")
mailObj.UseDefaultCredentials = False
mailObj.Credentials = basicAuthenticationInfo   

In both cases my emails are sent.

Looking at my SMTP settings in MailEnable

[General] tab
Local domain name: domain1.com
Default mail domain name: mail.domain1.com

This is causing my emails to be rejected by some mailservers as spam.

How can I configure Mail Enable to use the correct email headers that match the domain from which I'm sending, domain2 in this case?

UPDATE 1

DNS settings enter image description here

Adam
  • 247
  • 3
  • 4
  • 16

1 Answers1

1

Consistent host name is enough, you do not have to aim for matching domains between host and the mail it handles. Just make sure your server is not saying it is called mail.domain1.com while according to DNS, it is called h2134215.myisp.com.

How can I configure Mail Enable to use the correct email headers?

These trace headers are added by the next server, merely recording what has happened. They automatically record the new host name and PTR record as soon as you configure it. Consider them a symptom.

match the domain from which I'm sending

Your canonical server name should remain the same, regardless of which domain you are sending mail for. Thus, it cannot match two different domains. But it does not have to. You just have to configure one name, properly.

This is causing my emails to be rejected by some mailservers as spam.

Set the mail servers fully-qualified domain name to something that seems appropriate for both domains (could be mail.domain1.com, could be something entirely different from both domains) and register that hostname in DNS, preferably in both directions.

Then deploy SPF to let receiving servers automatically know which mail servers are authorized to send mail for which domains.

anx
  • 8,963
  • 5
  • 24
  • 48
  • Wow, thanks for the detailed explanation, not sure I understand it all, but I'll give it a shot :) If I understand you correctly, my Mail Enable setting `Default mail domain name: mail.domain1.com` (which is the fully-qualified domain name you're referring to) seems to be ok, it's mostly adding the right domain name to my DNS. I would need to add a `mail` A record with (for example) `mail.domain1.com` as value to both the DNS settings of domain1.com and domain2.com? – Adam Jun 30 '21 at 09:46
  • 1
    That does not sound quite right yet. The servers *name* goes into the PTR record for your IP, which you might have to configure in a completely different place than your A and AAAA records. The other direction, A->server name is just needed once - as I recommend your *one* server to use just *one* name. Then for SPF, either putting the name or the IPs is fine, but that is a whole topic on its own and you probably want to read some more about that before implementing. – anx Jun 30 '21 at 10:18
  • Thanks again. I checked out this: https://help.returnpath.com/hc/en-us/articles/220223568-What-is-a-pointer-PTR-record-. Not sure where else than DNS settings I can add that PTR record. I added a screenshot so you can see what I'm referring to. – Adam Jun 30 '21 at 14:40
  • 1
    @Flo try searching for `[hosting company/ISP name] PTR` – anx Jul 01 '21 at 00:02