vexim / vexim2

Virtual Exim 2
Other
70 stars 47 forks source link

Feature request: Specify sending IP address per domain #30

Open jrmyio opened 9 years ago

jrmyio commented 9 years ago

It would be awesome if you could set the sending IP address per domain.

I think this can be achieved relatively easy by setting the "interface" under "remote_smtp" as described in: https://loginroot.com/how-to-sending-emails-using-user-assigned-ip-in-exim-directadmin/

Udera commented 9 years ago

Exim4U provides some additional functions compared to vexim, AFAIK it contains handling of multiple IP addresses. I'm actually not sure about the future development of vexim....

Z3po commented 9 years ago

I couldn't find anything I currently miss with vexim in exim4u featurelist.... I don't think vexim is dead, it just took some time off :) Time to come back, isn't it?

rimas-kudelis commented 9 years ago

Patches for this feature are welcome. :) From looking at the howto, it seems a rather easy thing to implement. However, couple considerations should be made: 1) most important – domains without outbound IP specified should still work 2) less important – domains with incorrect IP address specified (i.e. some IP which the server is not using at the moment). I'm still unsure whether these should keep working or – on the contrary – stop working. This is open for discussion.

runout-at commented 6 years ago

On starting to use IPv6 i had to set the outgoing address because i have more than one IPv6 on the host and exim used the wrong one. My hack is to set a variable: in /etc/exim4/conf.d/main/00_vexim_listmacrosdefs OUTGOING_IP_ADDRESSES = y.y.y.y ; 2002::xxxx and in 2 transports: /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_smarthost

.ifdef OUTGOING_IP_ADDRESSES
  interface = <; OUTGOING_IP_ADDRESSES
.endif

it would be just another field in the domain table and a query instead the fixed variable (varchar 255?). I would volunteer to prepare a PR for that.

  1. What would you prefer as fallback if a domain has no IP set?
  2. How do we check if the IP is not a correct IP for the host or domain? Is this possible by MX lookups?
  3. As i modified the original exim transport files i'd be interested in a different solution without touching them. Its a hassle on later Debian upgrades if we change those. Ideas anyone?

Other/more ideas?

Udera commented 6 years ago

What would you prefer as fallback if a domain has no IP set?

I'm not really sure what your use case is. Is just a few domains and all the others work on the default IP?

How do we check if the IP is not a correct IP for the host or domain? Is this possible by MX lookups?

Is this possible (and does it take a long time), and should we do this every time you send a mail? Or in case sending fails (for whatever reason) we can catch this case and keep it in the retry-loop, tag it to be sent over default ip or freeze it?

Other/more ideas?

If we think about changing the sending process, we could as well integrate dkim.

runout-at commented 6 years ago

Sometimes it's a good idea to have separate IPs for different domains/customers. Even if an IP gets blacklisted. The default IP will be configured in the exim conf.d/main files and set during mail processing if no IP was retrieved from the database.

If there are more than one addresses in the list, exim will try them all before stopping the delivery with an error (if i understand the documentation right). Maybe the WebUI could be more complex and we could check/sanitize the values on input. I wouldn't do checks on every mail in exim. One could monitor the validity of the addresses with a cron job (hourly, daily,...). I'll prepare a sample shell script for that too.

Handling DKIM is similar but more difficult because generating DNS entries is more complex. At the moment i sign all messages with the same key.

runout-at commented 6 years ago

I asked the debian packagers to integrate the code for the transports in their package: http://lists.alioth.debian.org/pipermail/pkg-exim4-users/2018-April/thread.html#2385

runout-at commented 8 months ago

This was integrated in the default debian config in the file

by the block

.ifdef REMOTE_SMTP_INTERFACE
  interface = REMOTE_SMTP_INTERFACE
.endif

for my PR #245 this would need a config to read the IP from the database like:

VEXIM_OUTIP = SELECT DISTINCT out_ip FROM domains \
                           WHERE domain = '${quote_mysql:$sender_address_domain}' \
                               AND out_ip <> TRIM('')
OUTGOING_IP_DEFAULT = 2001:db8:: ; 10.0.0.1
REMOTE_SMTP_INTERFACE = ${lookup mysql{VEXIM_OUTIP}{ <; $value }{ <; OUTGOING_IP_DEFAULT }}