E-mail server via docker.internal on 127.0.0.1 of host?

Hi there,

I am wondering if I can access a local SMTP/IMAP server on the host that is running the docker container?

Docker provides the docker.internal networking to access the host, will this work when I use this as ERPNext mail server?
Is there a way to test this, initiate an email?

Reason is I use an encrypted email provider and access is only possible via a local bridge, offering SMTP and IMAP.

PS: I assume this is not feasible for helpdesk? For some reasons the helpdesk tool only provides pre-configured mail services?

Thx!
Tom

I think it is available on Mac and Windows.

On linux you can try 172.17.0.1 to access docker host.

Great, thanks for the input. I will try this out then.

Do you know of an easy way to trigger an email to verify the setup?

For development try mailpit,

I tried to use mailpit using the snippet you cited (also including the volume which is not in the snippet) in pwd.yml (a version also enabled for socketio to work as per the FAQ) and the container runs (it is accessible on 8025), but now I’m stuck configuring the /app/email-account/new-email-account- in ERPNext.

It rejects “mailpit” as a domain name.
mailpit.com” is fine, but then it errors out trying to connect to it, “frontend.localhost” also doesn’t work, and I didn’t hold my breath anyway with these two.

Now what?
How did you set email(s) up in ERPNext to send via mailpit?

I also tried to set the domain via /app/email-domain, but this doesn’t work because it requires an incoming email account (pop3/imap) which mailpit doesn’t provide*, and this can’t be skipped. I’m not sure anyway if it makes sense to follow this road (maybe somehow setting a dummy incoming mail server?).

* In fact, mailpit also does have a POP3 function which could be configured, too:

The mailpit documentation suggests procedures to test the running mailpit:

With the telnet method I could confirm it runs correctly by manually sending a test mail to localhost:1025 which immediately was notified by the mailpit inbox open in the browser at frontend.localhost:8025 (it also works at localhost:8025), so this url:port is where mailpit’s smtp is working.

From here it might be straightforward: Invent another domain name for a fictional smtp server which erpnext allows to configure (e.g. validation not complaining) for an outgoing email account, and setting a line in /etc/hosts of my localhost test machine to send the outgoing smtp connection to 127.0.0.1 for mailpit to take it and display the mails.

Straightforward it might have been, except that it doesn’t work. I set two new domain names (“hotzenplotz.mail” and “smtp.hotzenplotz.mail”) for 127.0.0.1 in /etc/hosts, and can repeat the smtp dance from a telnet connection to “smtp.hotzenplotz.mail”, and the mail appears in the mailpit’s inbox, but I can’t configure the email-account in ERPNext which complains about “Ungültiger Postausgang Server oder Port: [Errno -2] Name or service not known”, although I set smtp.hotzenplotz.mail and port 1025, as used with the telnet connection, as parameters.

Not clear how to solve this.

ERPNext: v15.50.1
Frappe Framework: v15.54.1

Check video here:

Thank you, Revant!
There are some “minor :rofl:” differences (e.g. you used the more recent v15.55.2, my pw wasn’t “admin”, different email and domain, didn’t start with devcontainer but pwd, maybe my /etc/hosts setting got in the way after all, and it could also be the network mailpit is attached to, that’s propably different between devcontainer and pwd) to how I did it, but I can’t check this ATM, but once back at the relevant build-and-test system, I’ll track down what’s the crucial one(s) (if not something else entirely).