How to configure Fetchmail with a remote IMAP server? #3994
-
For the past couple decades, I have had a hosted cPanel web account that includes an email server. This has been working well -- but I have been dealing with storage capacity issues. My goal is to have docker-mailserve & fetchmail connect to the remote server, download messages and present them to clients that connect locally to dms. DMS will never be exposed to the public. I have docker-mailserve installed and fetchmail is enabled. I have a user created in docker-mailserve and have successfully sent and received a test message to and from this account. But I don't see how to specify how to connect to the remote server. I've looked through the fetchmail documentation.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 17 replies
-
Please note that this response was created using generative AI, leveraging previously available information from the repository. This information may be helpful. However, it is our strong recommendation that you carefully consider the information before blindly applying it. To configure Fetchmail with Docker Mailserver (DMS) to connect to a remote server, download messages, and manage them locally, you need to follow these steps:
After setting up your This setup should allow you to achieve your goal of connecting to a remote IMAP server, downloading messages, and managing them locally without exposing DMS to the public. This comment was generated by Glime. |
Beta Was this translation helpful? Give feedback.
-
Local test between two DMS with fetchmailHere you go, this will let you try the feature locally with two instances of DMS. # compose.yaml
services:
dms-fetch:
image: ghcr.io/docker-mailserver/docker-mailserver:latest
hostname: mail.example.test
environment:
ENABLE_FETCHMAIL: 1
# We change this setting to 10 for quicker testing:
FETCHMAIL_POLL: 10
# Link the DNS lookup `remote.test` to resolve to the `dms-remote` container IP (for `@remote.test` address):
# This is only for this example, since no real DNS service is configured, this is a Docker internal DNS feature:
links:
- "dms-remote:remote.test"
# NOTE: Optional, You only need to publish ports if you want to verify via your own mail client.
#ports:
# - "465:465" # ESMTP (implicit TLS)
# - "993:993" # IMAP4 (implicit TLS)
# You'd normally use volumes here, for simplicity of the example, all config is contained within `compose.yaml`:
configs:
- source: dms-accounts-fetch
target: /tmp/docker-mailserver/postfix-accounts.cf
- source: fetchmail
target: /tmp/docker-mailserver/fetchmail.cf
dms-remote:
image: ghcr.io/docker-mailserver/docker-mailserver:latest
hostname: mail.remote.test
environment:
# Allows for us send a test mail easily by trusting any mail client run within this container (`swaks`):
PERMIT_DOCKER: container
# Alternatively, trust and accept any mail received from clients in same subnet of dms-fetch:
#PERMIT_DOCKER: connected-networks
configs:
- source: dms-accounts-remote
target: /tmp/docker-mailserver/postfix-accounts.cf
# Using the Docker Compose `configs.content` feature instead of volume mounting separate files.
# NOTE: This feature requires Docker Compose v2.23.1 (Nov 2023) or newer:
# https://github.com/compose-spec/compose-spec/pull/446
configs:
fetchmail:
content: |
poll 'mail.remote.test' proto imap
user '[email protected]'
pass 'secret'
is '[email protected]'
no sslcertck
# DMS requires an account to complete setup, configure one for each instance:
# NOTE: Both accounts are configured with the same password (SHA512-CRYPT hashed), `secret`.
dms-accounts-fetch:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.
dms-accounts-remote:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8. $ docker compose up
# John has no mail in his inbox (Your local DMS instance with fetchmail)
$ docker compose exec -it dms-fetch doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=0
# Jane has no mail in her inbox (Your remote DMS instance)
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=0
# Send the remote DMS a mail internally (PERMIT_DOCKER ENV allows to send this without authentication):
$ docker compose exec -it dms-remote swaks --server localhost --from [email protected] --to [email protected]
# Jane has mail now, until fetchmail takes it:
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=1
# Wait for fetchmail poll to pass, and check inboxes again,
# Fetchmail has retrieved Janes mail, deleting from her inbox, sending the copy to John's inbox:
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=0
$ docker compose exec -it dms-fetch doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=1 Fetchmail config
You can see that it works as intended. So please refer to this example and adapt it to your remote mail server. It should successfully be able to retrieve the mail. Then adapt the example to your actual mail server setup, and it should help you troubleshoot where the problem is 👍 Looking at our docs for fetchmail config, the settings are effectively the same in the example above as they are in the docs example. I don't see anything that I can update there, beyond mentioning this more complete example for local testing/verification? Docs also provide some debug advice: https://docker-mailserver.github.io/docker-mailserver/v13.3/config/advanced/mail-fetchmail/#debugging For any additional trobleshooting, be sure to check the logs from DMS. When Fetchmail has problems connecting, it should be logging messages like this:
As you can see, the connection to |
Beta Was this translation helpful? Give feedback.
Local test between two DMS with fetchmail
Here you go, this will let you try the feature locally with two instances of DMS.