# Using Gmail SMTP with gitea

**URL:** <https://forum.gitea.com/t/using-gmail-smtp-with-gitea/7973>\
**Category:** General\
**Created:** [October 14, 2023, 8:01pm UTC](https://forum.gitea.com/t/using-gmail-smtp-with-gitea/7973 "2023-10-14T20:01:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwoodpatrick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/mwoodpatrick/32/4102_2.png) [@mwoodpatrick](https://forum.gitea.com/u/mwoodpatrick)\
**Post date:** [October 14, 2023, 8:01pm UTC](https://forum.gitea.com/t/using-gmail-smtp-with-gitea/7973/1 "2023-10-14T20:01:00Z")

</div>

I’m trying to setup Gmail SMTP with gitea. I have the following settings:

[mailer]  
ENABLED = true  
FROM = my gmail address  
PROTOCOL = smtps  
SMTP\_ADDR = [smtp.gmail.com](http://smtp.gmail.com)  
SMTP\_PORT = 587  
USER = my gmail address  
PASSWD =my app password

I ran the command:

> gitea admin sendmail --title “Hello from Gitea” --content “This is a test”

and got:

> Proceed with sending email? [Y/n] y  
> Sent 1 email(s) to all users

The docker log shows:

> 2023/10/14 12:19:15 …eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/mail/send for 127.0.0.1:0, 200 OK in 10.2ms @ private/mail.go:25(private.SendEmail)

But I did not receive an email, any suggestions on what I am doing wrong or the best way to debug this issue

I changed the logging level to trace and reran and got the following output

> 2023/10/15 03:10:09 …s/process/manager.go:188:Add() [T] Start 652bba81: POST: /api/internal/mail/send (request)  
> 2023/10/15 03:10:09 …eb/routing/logger.go:47:func1() [T] router: started POST /api/internal/mail/send for 127.0.0.1:0  
> 2023/10/15 03:10:09 …ces/mailer/mailer.go:102:NewMessageFrom() [T] NewMessageFrom (body):  
> This is a test  
> 2023/10/15 03:10:09 …eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/mail/send for 127.0.0.1:0, 200 OK in 5.8ms @ private/mail.go:25(private.SendEmail)  
> 2023/10/15 03:10:09 …s/process/manager.go:231:remove() [T] Done 652bba81: POST: /api/internal/mail/send  
> 2023/10/15 03:10:10 …queue/workergroup.go:143:func1() [D] Queue “mail” starts new worker  
> 2023/10/15 03:10:10 …ces/mailer/mailer.go:409:func1() [T] New e-mail sending request [mwoodpatrick@gmail.com]:  
> 2023/10/15 03:10:10 …ces/mailer/mailer.go:411:func1() [E] Failed to send emails [mwoodpatrick@gmail.com]: - gomail: could not send email 1: could not initiate SMTP session: tls: first record does not look like a TLS handshake

---

<div class="post-metadata">

**Author:** ![remram44](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/remram44/32/3152_2.png) [@remram44](https://forum.gitea.com/u/remram44)\
**Post date:** [October 20, 2023, 4:51am UTC](https://forum.gitea.com/t/using-gmail-smtp-with-gitea/7973/2 "2023-10-20T04:51:40Z")

</div>

Either use:

- PROTOCOL=smtps and SMTP\_PORT=465, or
- PROTOCOL=smtp and SMTP\_PORT=587

The first one is recommended.

---

<div class="post-metadata">

**Author:** ![mwoodpatrick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/mwoodpatrick/32/4102_2.png) [@mwoodpatrick](https://forum.gitea.com/u/mwoodpatrick)\
**Post date:** [October 23, 2023, 10:25am UTC](https://forum.gitea.com/t/using-gmail-smtp-with-gitea/7973/3 "2023-10-23T10:25:40Z")

</div>

Many thanks that worked.
