mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 22:52:58 +03:00
🐛 Bug Report: Cannot send email through Gmail SMTP relay #390
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @iNenadnano on GitHub.
Reproduction steps
I have Gmail SMTP relay setup to accept email from specified email addresses with no authentication and encryption on port 25.
Pocked ID configuration is as follows:
smtp-relay.gmail.com25SMTP From is set as well, TLS is not checked.
Expected behavior
Upon pressing Send test email button, I was expecting the email to be sent.
Actual Behavior
However, an error is presented in UI stating Failed to send test email. Check the server logs for more information.
If logs, the following line is recorded:
@iNenadnano commented on GitHub:
@kmendell no it is not, I am using setup as described in this article. I have failed to mention that it is for Google Workspace. Here's the configuration:
@stonith404 I have tried with both my email address and a generic one, like
id@domain.com.edited to include Google Workspace comment
@iNenadnano commented on GitHub:
It works with many other services, like Metabase, Vaultwarden, OpenProject, my scanner...
@kmendell commented on GitHub:
@iNenadnano Is this a custom Email relay? I thought Gmail's SMTP Server required authenication , maybe ive never seen what your using though..
@stonith404 commented on GitHub:
What did you set for "SMTP From"?
@stonith404 commented on GitHub:
@iNenadnano Does SMTP work with any other service or is Pocket ID the only one you're using this SMTP server?
@kmendell commented on GitHub:
@iNenadnano Okay was just curious to see if the change we did to the email service in 0.27 effected this at all, but it looks like it didnt, i dont have google workspaces otherwise id spin up a test instance and test... im assuming you need to pay to use that relay? Could you try to use gmail standard email smtp server and see if that works , just as another test.
@iNenadnano commented on GitHub:
It is a fresh deployment using
docker-compose, version 0.27.0.@iNenadnano commented on GitHub:
Couldn't find v0.26.1 tag on docker hub, so I tried with v0.26 with same result.
@kmendell commented on GitHub:
Out of curiosity, Could you try deploying 0.26.1 on a fresh database and see if the issue still happens?
@kmendell commented on GitHub:
What version of Pocket ID did you deploy and see this issue? Was it a fresh deployment ? or a upgrade from a old release?
@iNenadnano commented on GitHub:
@stonith404 I have pulled the development image and I am getting the following error now:
@kmendell unfortunately, I do nothing think it is possible as it's Google's server. I cannot find anything with the sender address that I have specified in the logs available to me, which seems logical as the email never got sent.
@kmendell commented on GitHub:
@iNenadnano If other servers work as expected, it makes me thing its something miss configured on the google end? maybe im wrong, sicne that works with other services. Can you see any logs inside google that would help troubleshoot?
@stonith404 commented on GitHub:
@iNenadnano I think I have identified the error. Could try the
stonith404/pocket-id:developmentimage?It seems the SMTP client is sending “localhost” as the EHLO hostname, which Google rejects. Interestingly, other providers typically accept “localhost” without any issues.
@kmendell commented on GitHub:
@stonith404 @iNenadnano A theory we came up with after talking to someone i know, Could the docker container hostname maybe be causing a issue?
@iNenadnano commented on GitHub:
Yes, SMTP relay service is a feature of Google Workspace and needs to be paid.
As for standard Gmail SMTP server, it works as expected.
@stonith404 commented on GitHub:
I think the hostname is not relevant because the EHLO host gets derived from the "PUBLIC_APP_URL.
@iNenadnano Did you have to set a EHLO or HELO value in your other services that are using the same SMTP server?
@iNenadnano commented on GitHub:
It seems that the problem is in line 71 of smtp.go where
localhostis hard coded. If I put something different, email gets sent successfully.@iNenadnano commented on GitHub:
@stonith404 I did not have to set any of those values.
FYI, this piece of LLM generated code (as I am not at all familiar with go) works without any issues:
Example function from here fails:
@kmendell commented on GitHub:
@iNenadnano Im pretty sure that's what stonith fixed earlier today see below, when using the development image can you attach more than the one log, from the output of the docker container? im curious if this function he added is getting called or not...
@iNenadnano commented on GitHub:
In my case it is like this:
@stonith404 commented on GitHub:
Did you replace
localhostin the script the LLM has generated on the following line?_, err = fmt.Fprintf(conn, "HELO localhost\r\n")I've pushed a new
developmentimage where I hard-coded the HELO message tosample.com. Could you try if this works?@stonith404 commented on GitHub:
Great, thanks for testing it so quickly.
Would you mind to test the
developmentimage again 😅? The HELO argument should now be the host (get fromos.Hostname()).@stonith404 commented on GitHub:
Yeah exactly. It now takes the domain from the
PUBLIC_APP_URLas the EHLO argument. @iNenadnano Could it be that yourPUBLIC_APP_URLis set tohttp(s)://localhost?@iNenadnano commented on GitHub:
@kmendell Full log output of newly created container from the development image is as follows:
@stonith404
.envfile is as follows and I am running the container behindcaddyas a reverse proxy:@iNenadnano commented on GitHub:
@stonith404 correct, that was the line I replaced.
It works now with the latest
developmentimage!@stonith404 commented on GitHub:
Fixed in
0.27.1.@iNenadnano commented on GitHub:
Tested and working! Thank you!