Different sender based SMTP route for outgoing emails

Use this forum if you want to suggest a new feature to hMailServer. Before posting, please search the forum to confirm that it has not already been suggested.
Post Reply
pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-05 20:11

Hello,

We would like to use hMailserver as a relay for all our outgoing emails to the Internet. Our outgoing emails are coming from Exchange servers with 3 different sender domains. We have to use 3 different Target SMTP hosts using 3 different SMTP routes. We do many tests with SMTP routes and Rules without success. Our outgoing emails are always sent directly to the recipient domains mx servers, hMailserver using DNS resolution. Our main problem is I cannot create 3 different SMTP routes with domain *. What is the solution, right configuration ?

Regards,
Philippe

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Different sender based SMTP route for outgoing emails

Post by ^DooM^ » 2011-06-05 22:53

The question was somewhat confusing, You want to send specific outbound email via external SMTP smarthosts from hMail?

domain1 sent via SH1
domain2 sent via SH2
domain3 sent via SH3
All other sent direct?
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-05 23:08

Sorry. Right, I want to send specific outbound email via external SMTP smarthosts from hMail but depending on sender domain, not based on recipent domain.

domain1 sent via SH1 ==> domain1 is our first sender domain (emails from local users from Exchange)
domain2 sent via SH2 ==> domain2 is our second sender domain (emails from local users from Exchange)
domain3 sent via SH3 ==> domain3 is our third sender domain (emails from local users from Exchange)
All other sent direct? ==> no, we have no other sender domain

Regards,
PP

User avatar
mattg
Moderator
Moderator
Posts: 21025
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Different sender based SMTP route for outgoing emails

Post by mattg » 2011-06-06 02:04

A global rule calling a route I think



For each smart host route

Create a route
Create a global rule (If sender matched then use route)
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-06 09:02

To do an easy test, I start with only one sender domain.

In Rules, I create only one rule with :
Name = Global
Criteria = from + contains + domain1
Actions = Send using route *
In SMTP routes, I create only one route with :
Name = *
Smarthost = DNS name of our first smarthost
port = 25
When sender matches route, treat sender as = a local email address
When recipient matches route, treat sender as = a remote email address
In Protocol/SMTP/Delivery of email/SMTP Relayer, Remote host name is empty

But still, hMailServer uses the DNS resolution, the full log is attached. What is my error in configuration ?

...
"SMTPD" 3212 53 "2011-06-06 09:11:59.937" "192.168.208.78" "RECEIVED: DATA"
"SMTPD" 3212 53 "2011-06-06 09:11:59.937" "192.168.208.78" "SENT: 354 OK, send."
"DEBUG" 2004 "2011-06-06 09:12:01.828" "Saving message: C:\Program Files (x86)\hMailServer\Data\{ED0317FA-461B-4554-83C8-902C59BE2C7F}.eml"
"DEBUG" 2004 "2011-06-06 09:12:01.843" "Requesting SMTPDeliveryManager to start message delivery"
"SMTPD" 2004 53 "2011-06-06 09:12:01.859" "192.168.208.78" "SENT: 250 Queued (1.891 seconds)"
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Delivering message..."
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Applying rules"
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Applying rule"
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Performing local delivery"
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Local delivery completed"
"DEBUG" 3416 "2011-06-06 09:12:01.859" "Performing external delivery"
"TCPIP" 3416 "2011-06-06 09:12:01.859" "DNS - MX Lookup: softhome.net"
"TCPIP" 3416 "2011-06-06 09:12:01.875" "DNS - MX Result: 5 IP addresses were found."
"DEBUG" 3416 "2011-06-06 09:12:01.875" "SD::_InitiateExternalConnection"
"DEBUG" 3416 "2011-06-06 09:12:01.875" "Creating session 54"
"TCPIP" 3416 "2011-06-06 09:12:01.875" "Connecting to 66.54.152.40..."
"DEBUG" 3416 "2011-06-06 09:12:03.796" "SD::~_InitiateExternalConnection-5"
"DEBUG" 3416 "2011-06-06 09:12:03.796" "Ending session 54"
"DEBUG" 3416 "2011-06-06 09:12:03.796" "SD::_InitiateExternalConnection"
"DEBUG" 3416 "2011-06-06 09:12:03.796" "Creating session 55"
"TCPIP" 3416 "2011-06-06 09:12:03.796" "Connecting to 66.54.152.4..."
...


Regards,
PP
Attachments
hmailserver_2011-06-06.zip
(2.16 KiB) Downloaded 283 times

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Different sender based SMTP route for outgoing emails

Post by ^DooM^ » 2011-06-06 10:23

Did you call the route * for any particular reason? In the route try using the IP address rather than the hostname.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-06 10:49

I call the route * because in the documentation it's specified :
Domain : The domain that this route should be applied to. The domain name is case insensitive.
So, because external recipients have any domain, I specify *.

In the route, I try using the IP address rather than the hostname, hMailServer still uses DNS, not the route.

In the route I try also to rename it to "Any", hMailServer still uses DNS, not the route.

"DEBUG" 1988 "2011-06-06 11:46:17.625" "SMTPDeliveryManager::Start()"
"DEBUG" 2576 "2011-06-06 11:46:17.625" "ExternalFetchManager::Start()"
"TCPIP" 2548 "2011-06-06 11:46:17.640" "TCPConnection - Posting AcceptEx on 192.168.208.237:25"
"TCPIP" 3416 "2011-06-06 11:46:23.156" "TCPConnection - Posting AcceptEx on 192.168.208.237:25"
"DEBUG" 3416 "2011-06-06 11:46:23.156" "Creating session 59"
"SMTPD" 3416 59 "2011-06-06 11:46:23.156" "192.168.208.78" "SENT: 220 mail.groupe-marill.dj ESMTP"
"SMTPD" 752 59 "2011-06-06 11:46:24.093" "192.168.208.78" "RECEIVED: EHLO dis-pro.net"
"SMTPD" 752 59 "2011-06-06 11:46:24.093" "192.168.208.78" "SENT: 250-mail.groupe-marill.dj[nl]250-SIZE 10240000[nl]250 AUTH LOGIN"
"SMTPD" 832 59 "2011-06-06 11:46:24.109" "192.168.208.78" "RECEIVED: MAIL FROM p.perles@dis-pro.net"
"SMTPD" 832 59 "2011-06-06 11:46:24.109" "192.168.208.78" "SENT: 250 OK"
"SMTPD" 920 59 "2011-06-06 11:46:24.109" "192.168.208.78" "RECEIVED: RCPT TO: p.perles@softhome.net"
"SMTPD" 920 59 "2011-06-06 11:46:24.109" "192.168.208.78" "SENT: 250 OK"
"SMTPD" 832 59 "2011-06-06 11:46:24.125" "192.168.208.78" "RECEIVED: DATA"
"SMTPD" 832 59 "2011-06-06 11:46:24.125" "192.168.208.78" "SENT: 354 OK, send."
"DEBUG" 2004 "2011-06-06 11:46:25.562" "Saving message: C:\Program Files (x86)\hMailServer\Data\{ADC11781-76B0-47BB-B960-447842690DAF}.eml"
"DEBUG" 2004 "2011-06-06 11:46:25.562" "Requesting SMTPDeliveryManager to start message delivery"
"SMTPD" 2004 59 "2011-06-06 11:46:25.562" "192.168.208.78" "SENT: 250 Queued (1.438 seconds)"
"DEBUG" 328 "2011-06-06 11:46:25.578" "Delivering message..."
"DEBUG" 328 "2011-06-06 11:46:25.578" "Applying rules"
"DEBUG" 328 "2011-06-06 11:46:25.578" "Applying rule"
"DEBUG" 328 "2011-06-06 11:46:25.578" "Performing local delivery"
"DEBUG" 328 "2011-06-06 11:46:25.578" "Local delivery completed"
"DEBUG" 328 "2011-06-06 11:46:25.578" "Performing external delivery"
"TCPIP" 328 "2011-06-06 11:46:25.578" "DNS - MX Lookup: softhome.net"
"TCPIP" 328 "2011-06-06 11:46:25.593" "DNS - MX Result: 5 IP addresses were found."
"DEBUG" 328 "2011-06-06 11:46:25.593" "SD::_InitiateExternalConnection"
"DEBUG" 328 "2011-06-06 11:46:25.593" "Creating session 60"
"TCPIP" 328 "2011-06-06 11:46:25.593" "Connecting to 66.54.152.40..."
"SMTPD" 3552 59 "2011-06-06 11:46:27.187" "192.168.208.78" "RECEIVED: QUIT"
"SMTPD" 3552 59 "2011-06-06 11:46:27.187" "192.168.208.78" "SENT: 221 goodbye"
"DEBUG" 2188 "2011-06-06 11:46:27.187" "Closing TCP/IP socket"
"DEBUG" 2188 "2011-06-06 11:46:27.187" "Ending session 59"
"DEBUG" 328 "2011-06-06 11:46:27.531" "SD::~_InitiateExternalConnection-5"
"DEBUG" 328 "2011-06-06 11:46:27.531" "Ending session 60"
"DEBUG" 328 "2011-06-06 11:46:27.531" "SD::_InitiateExternalConnection"
"DEBUG" 328 "2011-06-06 11:46:27.531" "Creating session 61"
"TCPIP" 328 "2011-06-06 11:46:27.531" "Connecting to 66.54.152.36..."
"DEBUG" 3752 "2011-06-06 11:46:30.671" "SMTPClientConnection::_ParseASCII()"
"SMTPC" 3752 61 "2011-06-06 11:46:30.671" "66.54.152.36" "RECEIVED: 220-lap ESMTP qpsmtpd 0.29/lap/7 ready; send us your mail, but not your spam."

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Different sender based SMTP route for outgoing emails

Post by ^DooM^ » 2011-06-06 10:54

You cant wildcard a route, you have to specify a domain name. What you seem to be suggesting is using multiple SMTP relays rather than routes.

So if the sender is from domain one, send all of their emails through to any domain through relayserver 1, if sender from domain 2, send all their email regardless of domain, through relay server 2? Is this what you want?
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-06 11:03

Yes.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Different sender based SMTP route for outgoing emails

Post by ^DooM^ » 2011-06-06 11:15

Right hMail cant do this, and there is already a poll running for this feature request.

http://www.hmailserver.com/forum/viewto ... =2&t=16734

You could possibly create a script to do this but that entirely depends on your programming skill. I'll move this to archive shortly as it's a duplicate request.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-06-06 11:29

Do you mean hMail cannot do this with standard screens, but it's possible with a script ?

PP

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Different sender based SMTP route for outgoing emails

Post by ^DooM^ » 2011-06-06 11:38

You cannot do this with a standard hMail install, what you could possibly do is use the ComAPI to read the sender domain from the connecting client and if it matches one of your senders, update the SMTP relayer fields, using hMails onaccept event.

The only problem I see with doing that is if you send multiple emails at the same time to different domains that require multiple SMTP relayer settings, it could end up being relayed through a different server than intended due to hMails multi threaded nature.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

alex303_exchange
New user
New user
Posts: 1
Joined: 2011-08-08 23:28

Re: Different sender based SMTP route for outgoing emails

Post by alex303_exchange » 2011-08-09 00:10

Hi,

i found a way to do this what pperles means, and it works just fine with hMailserver !
I use hMailserver with my ExchangeSever, but it will work for every other Mailing System too !

What i done is: use hMailserver as a "SMTP-Router" based on Sender Address an used "Rules and Routing" to get the message send thru the suitable SMTP Server for each Sender.

It was easiely to configure !

1. Fresh install of hMailserver !!! (No Domain Setup is neccesary in hMailserver) !!!
2. change SMTP Port to 26 (because Exchange runs on Port 25 an it must stay there for Mail Recieve"
3. Allow hmailserver to accept "external to external" Mails without authentification
4. Set IP Range "localhost" only (prevent open Relay !)

5. Set up Smtp-Routings: for each sender@domain.org) to be delivered to specified SMTP Server with suitable Auth.
when sender and recipient matches route treat both as "remote email address" !

6. Set up Rules: for each Sender: From (contains: sender@domain.org) -> send using Route: SMTP_route defined on step5.


Finish !!!

Now my ExchangeServer sends all outbound Mails to hMailserver on localhost Port 26 and hMailserver SenderBasedRoutes the Mail to the Sender-suitable SMTP Host !!!!

Works absolutly fine !!!!!

this could be used for your configuration too, slightly changed for your needs !

*Sorry for bad grammer, i´m not an english man !

pperles
New user
New user
Posts: 16
Joined: 2011-06-05 17:56

Re: Different sender based SMTP route for outgoing emails

Post by pperles » 2011-10-08 11:41

Hello,

Your message is interesting. I try your configuration but it doesn-t work for me. In step 5. Set up Smtp-Routings, when I specify our sender domain and our dedicated external smtp server, hMailServer use DNS MX resolution and send the emails to the smtp server of the recipient domain and not to our external smtp server. When I specify in Set up Smtp-Routings the recipient domain and our dedicated external smtp server, hMailServer send correctly emails to our external smtp server.

Why we don't get the same result as you ? Do you have any idea ?


PP

benito80
New user
New user
Posts: 1
Joined: 2011-10-30 18:12

Re: Different sender based SMTP route for outgoing emails

Post by benito80 » 2011-10-30 18:14

Hello,

as for pperles, i configured my hmailserver like Alex did but it doesn't work...

hmailserver still use default smarthost (or MX if nothing configured)...

Any workaround ?

Post Reply