• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved How to define a custom SMTP Relay for one domain?

Lrnt

Basic Pleskian
Hi,

After some researches, I found that it is not possible to define a custom SMTP Relay for a specific domain through Plesk. I read some posts in this forum saying that it is possible by modifying postfix (transport, main.cf etc.).

Can someone explain the steps to perform that very simply?

Goals :
  • Define specific SMTP for a specific domain
  • Other domains must use the default SMTP (The one from the server)
Additionnaly, if you can tell me how to check if emails are sent via the custom SMTP Relay or the default one, it would be great.

I use Plesk Onyx Version 17.8.11 on Debian 9.8 and Postfix 3.1.12

Thank you!
Laurent
 
Hi Lrnt,

It is just a guess, maybe a CMS (for that domain) allows you to set up a custom SMTP relay in CMS's settings?


Additionnaly, if you can tell me how to check if emails are sent via the custom SMTP Relay or the default one, it would be great.
It is possible to understand based on mail's headers, I think this link can help: How to Get Email Headers – A Guide from MxToolBox. If you see in headers custom SMTP relay, it was delivered via the custom SMTP relay.

As an example, headers from an email that I received after registration on the talk.plesk.com forum :).

We can see here three steps/stops (from down to up):
3) From the forum to local mail sub-system;
2) From local mail sub-system to mx.google.com
1) From mx.google.com to somewhere locally in Google into my mailbox.

Code:
[...] ===> 1) <====
Received: by 10.28.149.194 with SMTP id x185csp106247wmd;
        Thu, 24 Nov 2016 01:41:16 -0800 (PST)
[...] ===> 2) <====
Received: from talk.plesk.com (talk.plesk.com. [195.214.233.100])
        by mx.google.com with ESMTPS id x199si16635631lff.338.2016.11.24.01.41.15
        for <[email protected]>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 24 Nov 2016 01:41:16 -0800 (PST)
[...] ===> 3) <====
Received: from talk.plesk.com (localhost [127.0.0.1]) by talk.plesk.com (8.14.4/8.14.4) with ESMTP id uAO9fFLb009366 for <[email protected]>; Thu, 24 Nov 2016 01:41:15 -0800
Received: (from apache@localhost) by talk.plesk.com (8.14.4/8.14.4/Submit) id uAO9fEN6009365; Thu, 24 Nov 2016 01:41:14 -0800
[...]
Subject: Plesk Forum Account Confirmation Required
From: Plesk Forum <[email protected]>
Date: Thu, 24 Nov 2016 09:41:14 +0000
[...]
 
Thanks for the reply.

Sorry, nothing to do with a CMS, it's just the classic use of mailboxes.

On a specific domain, I need to use an external SMTP Relay.
And on the others, the default SMTP (The one of my dedicated server)

What I need is a simple explanation to do this with postfix.
If an expert knows that, it wiil be awesome.

Thank you for the tip about mail header, I had forgotten about it! ;)
 
Assuming that:
- the domain in question (e.g. example.com) will have no mailboxes on your dedicated server (so no IMAP or POP3 either)
- the software running on the example.com (such as contact forms, PHP scripts, etc.) will use external SMTP directly to send any outgoing messages

than you should:
- in Plesk, under the example.com Mail Settings, untick "Activate mail service on this domain"
- adjust the DNS MX record for the example.com to point to the external SMTP
- adjust the DNS SPF record to include the external SMTP
- adjust the DNS DKIM record.

From now on, all mail settings for the example.com (such as mail account creation, etc.) will have to be performed on the external IMAP/POP3/SMTP server, not through Plesk. Settings for the mail clients (such as Outlook, Thunderbird, K9 for Android, etc.) will have to be adjusted according to the settings of the external IMAP/POP3/SMTP.
 
Hi

I think this is posible in easy way, as I understand you want use smarthost or external relay for just one domain

You can configure this in header_checks file if you use postfix -> Postfix manual - header_checks(5)

I use some similar to relay determinate mails from determinate server

For example, I want some times use diferent smarthost -> send mails to gmail from smarthost1, sendmails to hotmail from smarthost2

In same way you can configure it and if you have domain1.com domain2.com and domain3.com

And want than you domain2.com use your smarthost1 and domain2.com and domain3.com use your local SMTP

So configure your cheader_check file for scan domian2.com header and relay it from orther server.
 
I really appreciate your answers. However, I have to say that this has nothing to do with a PHP script or a CMS sending emails.

My issue is simple "specify an external smtp relay for one domain only". This SMTP relay must be used by the mailboxes of this specific domain.

For example, I need to use smtp.external.com for mydomain1.com and default SMTP server for all other domains I have. That's all.

@Ohya is the closest of what I need. @Ohya, can you provide me an example of what to add/modify in postfix header_check?

I don't need to use smarthost1 for gmail or smarthost2 for hotmail. I just need to send all messages from all mailboxes @example.com through an external relay (example smtp.external.com).

And, of course, I am not going to "untick "Activate mail service on this domain"" because I need it! ;)

Thank you :D
 
@Ohya is the closest of what I need. @Ohya, can you provide me an example of what to add/modify in postfix header_check?

First enable your header_hecks in main.cnf

Then in header_checks file add some like this

/^From: (.*)yourdomain.tld/ FILTER smtp:your.smtprelay.com_or_IP

or

/^from: (.*)yourdomain.tld/ FILTER smtp:your.smtprelay.com_or_IP

This should work

You can change FROM for TO or subject etc as you need filter mail

Never test with from but with /^to: (.*)yourdomain.tld/ work as spected, so maybe you need review headers and se if in what more is sended with from: and add it to filter

Not can help much more, not have any postfix now for test but you have the idea.
 
Thanks @Ohya for your tips.
I think it is a good way to achieve this.

To be honest, I am not going to try because, my "issue" concerns 5 mailboxes, so I configured the external SMTP directly on client software and I really don't want to break emails services on my server so...

For the next who are looking to this, I suggest you to vote for this feature here: Smarthost/External SMTP

The best would be to be able to manage this directly through Plesk for each domain or even better for each mail account :eek:
 
Hi @Lrnt,

I understand the concept you need, I was also searching for the same. Voted for the feature. I am currently doing some R&D on the same. I will keep you posted my results.
 
Back
Top