[GH-ISSUE #596] Not able to relay using GMail #383

Closed
opened 2026-03-15 14:09:51 +03:00 by kerem · 4 comments
Owner

Originally created by @ppuri on GitHub (Dec 20, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/596

First of all, thanks a ton for this wonderful tool.

I am trying to use it an SMTP sink in dev environment and then relay to real email id using GMail SMTP for customer testing, so that they can receive the actual email as well.

I have setup Gmail with an App Password and have setup a relay.yaml with settings given in documentation as below

host: smtp.gmail.com
port: 587
starttls: true
username: my-gmail-id@gmail.com
password: my-16char-app-pawword
from: my-gmail-id@gmail.com

and then starting mailpit with this command

mailpit.exe --db-file mails.db --webroot=/mail  --smtp-relay-config relay.yaml --smtp-relay-all  --verbose --log-file mailpit.log`

However, when it comes to relaying Mailpit throws this error in log

time="2025/12/21 00:52:05" level=error msg="[relay] error: error sending MAIL command: 530 5.7.0 Authentication Required. For more information, go to\n5.7.0 https://support.google.com/accounts/troubleshooter/2402620. d9443c01a7336-2a2f3c65d66sm50829075ad.20 - gsmtp"

To isolate if this is Mailpit issue or Gmail issue, I configured sendmail in xampp using the exact same config (same username/ password/ port), and sendmail is able to send the email using these settings. After this test, it appears that Mailpit is perhaps using a different way to authenticate to Gmail as compared to what sendmail is using.

Is it something that can be fixed please?

Originally created by @ppuri on GitHub (Dec 20, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/596 First of all, thanks a ton for this wonderful tool. I am trying to use it an SMTP sink in dev environment and then relay to real email id using GMail SMTP for customer testing, so that they can receive the actual email as well. I have setup Gmail with an App Password and have setup a relay.yaml with settings given in documentation as below ``` host: smtp.gmail.com port: 587 starttls: true username: my-gmail-id@gmail.com password: my-16char-app-pawword from: my-gmail-id@gmail.com ``` and then starting mailpit with this command ``` mailpit.exe --db-file mails.db --webroot=/mail --smtp-relay-config relay.yaml --smtp-relay-all --verbose --log-file mailpit.log` ``` However, when it comes to relaying Mailpit throws this error in log ``` time="2025/12/21 00:52:05" level=error msg="[relay] error: error sending MAIL command: 530 5.7.0 Authentication Required. For more information, go to\n5.7.0 https://support.google.com/accounts/troubleshooter/2402620. d9443c01a7336-2a2f3c65d66sm50829075ad.20 - gsmtp" ``` To isolate if this is Mailpit issue or Gmail issue, I configured sendmail in xampp using the exact same config (_same username/ password/ port_), and sendmail is able to send the email using these settings. After this test, it appears that Mailpit is perhaps using a different way to authenticate to Gmail as compared to what sendmail is using. Is it something that can be fixed please?
kerem closed this issue 2026-03-15 14:09:56 +03:00
Author
Owner

@ppuri commented on GitHub (Dec 21, 2025):

Since I reported this issue, I have been trying alternate solutions and I have got one approach working now for relaying emails from Mailpit via Gmail SMTP.

So, I have setup an hMailServer locally and using that to relay using Gmail, which worked straight away. And then setup Mailpit relay to hMailServer running on localhost:25 and Mailpit liked it 👍.

However, this obviously needed some research and extra setup, it would be ideal if Mailpit can be fixed to honour Gmail SMPT settings directly without need of another proxy.

<!-- gh-comment-id:3678252969 --> @ppuri commented on GitHub (Dec 21, 2025): Since I reported this issue, I have been trying alternate solutions and I have got one approach working now for relaying emails from Mailpit via Gmail SMTP. So, I have setup an [hMailServer](https://www.hmailserver.com/) locally and using that to relay using Gmail, which worked straight away. And then setup Mailpit relay to hMailServer running on localhost:25 and Mailpit liked it 👍. However, this obviously needed some research and extra setup, it would be ideal if Mailpit can be fixed to honour Gmail SMPT settings directly without need of another proxy.
Author
Owner

@axllent commented on GitHub (Dec 21, 2025):

Ho @ppuri. I haven't tested this... but it should work. What I know about Gmail is that it won't accept the "from" unless it is already preconfigured in your profile (to avoid spam being relayed), which is what I believe you are trying to do by setting the from: my-gmail-id@gmail.com value in your configuration. Assuming this is correct, then this will be the issue here - it's not called from in Mailpit, it's override-from: my-gmail-id@gmail.com. See https://mailpit.axllent.org/docs/configuration/smtp-relay/

Please confirm if this solves your issue?

<!-- gh-comment-id:3678347827 --> @axllent commented on GitHub (Dec 21, 2025): Ho @ppuri. I haven't tested this... but it should work. What I know about Gmail is that it won't accept the "from" unless it is already preconfigured in your profile (to avoid spam being relayed), which is what I believe you are trying to do by setting the `from: my-gmail-id@gmail.com` value in your configuration. Assuming this is correct, then this will be the issue here - it's not called `from` in Mailpit, it's `override-from: my-gmail-id@gmail.com`. See https://mailpit.axllent.org/docs/configuration/smtp-relay/ Please confirm if this solves your issue?
Author
Owner

@ppuri commented on GitHub (Dec 21, 2025):

@axllent Thanks for your reply. This was definitely an oversight on my end to use from: instead of override-from:. However changing that alone did not fix the issue. However, it made me review all the other settings for smtp-relay. Finally, I have got it working. It worked after I also used auth: and return-path: as well in the config

Thanks to your message, as it forced me review all the settings again and make it work.

Below is the final yaml, that worked

host: smtp.gmail.com
port: 587
starttls: true

auth: plain
username: my-gmail-id@gmail.com
password: my-16char-app-pawword

override-from: my-gmail-id@gmail.com
return-path: my-gmail-id@gmail.com

<!-- gh-comment-id:3678440385 --> @ppuri commented on GitHub (Dec 21, 2025): @axllent Thanks for your reply. This was definitely an oversight on my end to use `from:` instead of `override-from:`. However changing that alone did not fix the issue. However, it made me review all the other settings for smtp-relay. Finally, I have got it working. It worked after I also used `auth:` and `return-path:` as well in the config Thanks to your message, as it forced me review all the settings again and make it work. Below is the final yaml, that worked ``` host: smtp.gmail.com port: 587 starttls: true auth: plain username: my-gmail-id@gmail.com password: my-16char-app-pawword override-from: my-gmail-id@gmail.com return-path: my-gmail-id@gmail.com ```
Author
Owner

@axllent commented on GitHub (Dec 21, 2025):

Excellent, thanks for the feedback. Yes, if the reply-to is set in your email and does not align with the configured email address(es) in Gmail, then Gmail will probably block you too.

<!-- gh-comment-id:3678504823 --> @axllent commented on GitHub (Dec 21, 2025): Excellent, thanks for the feedback. Yes, if the `reply-to` is set in your email and does not align with the configured email address(es) in Gmail, then Gmail will probably block you too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#383
No description provided.