0

I need to deliver incoming mail from my local MTA into a (remote) IMAP mailbox. Is there a tool which can do that?

I cannot deliver the mail via SMTP because the remote system's spam filters etc. are too restrictive and don't reliably allow "simple" mail forwarding.

The local MTA is exim4. That's unlikely to change but I'm open to suggestions (it's my personal server). I do not have any access to the remote system, other than the IMAP account of course.

I know about offlineimap and similar programs; however, my goal is to not store the mail locally.

1 Answers1

0

May be the most straightforward approach is to use ssh as local delivery agent.

You have to modify the router for local delivery that way:

begin routers
. . . . . 
local:
    driver      = accept
    domains     = +local_domains
    transport   = remote_delivery
. . . . . 

and transport:

begin transports
. . . . . 
remote_delivery:
    driver      = pipe
    command     = /path/to/ssh -i /path/rsa_key user@remote.tld \
                  deliver -d \$local_part@\$domain -f \$sender_address
. . . . . 

Each time local MTA want to deliver the message locally, remote_delivery transport will be activated. ssh will establish the keyfile-authorized connection to the remote host, then invoke the deliver utility and then pass the message to its stdin. And the deliver utility will do all the rest.

Kondybas
  • 6,964
  • 2
  • 20
  • 24
  • Unfortunately delivery via IMAP is mandatory. I don't have ssh to the remote host. – Matthias Urlichs Nov 20 '17 at 21:46
  • Do you have any permission to manipulate email at all? – Kondybas Nov 20 '17 at 22:56
  • Other than using IMAP to upload a new email to the remote: no. (I already updated the question to clarify that.) – Matthias Urlichs Nov 21 '17 at 06:17
  • Delivery isn't performed via IMAP. Delivery is the process in between of SMTP and IMAP. Most of MTAs and POP/IMAP servers include some LDA functionality but that functionality does not related to the IMAP at all. If you want to perform local delivery on some host you need enough rights to launch utilities on this host. – Kondybas Nov 21 '17 at 09:29
  • Delivery is the process that gets the message from your local SMTP agent and stores it in a mailbox. It's perfectly possible to read a RFC822 message from stdin and upload it to some remote inbox via IMAP. The only problem seems to be is that nobody has written a tool that does this yet. – Matthias Urlichs Nov 21 '17 at 12:57
  • It is impossible to upload something via IMAP. Even `doveadm sync` that syncronize mail storages, uses direct TCP connections between hosts or `ssh` as transport. IMAP is similar to HTTP - you can see the content of storage and perform some predefined actions but can't upload anything to the server. You can deliver message through the local pipe or use `ssh` stdout-stdin passthrough. If you do not have enough rights on the remote server - you are not authorized to manipulate mail storage on it. – Kondybas Nov 21 '17 at 14:34
  • What do you mean "it's impossible to upload something IMAP"? Care to explain what the semantics of IMAP's "APPEND" command (RFC 3501 #6.3.11) are, if not that? Or how else tools like offlineimap do their job, if all you configure are two IMAP accounts? – Matthias Urlichs Nov 21 '17 at 20:33