Score:0

Mail Enable email headers when sending emails via ASP.NET

ar flag

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: <[email protected]>

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("[email protected]", "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

Score:1
fr flag
anx

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.

Adam avatar
ar flag
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?
anx avatar
fr flag
anx
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.
Adam avatar
ar flag
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.
anx avatar
fr flag
anx
@Flo try searching for `[hosting company/ISP name] PTR`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.