Not able to send out gmail smtp setting

hi, may I know how I can using gmail smtp to send out email?
I been configure the setting

GitLab email server settings

###! Docs: SMTP settings | GitLab
###! Use smtp instead of sendmail/postfix.

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.gmail.com
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “abc@gmail.com
gitlab_rails[‘smtp_password’] = “xxxx”
gitlab_rails[‘smtp_domain’] = “smtp.gmail.com
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = false
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

Email Settings

gitlab_rails[‘gitlab_email_enabled’] = true

##! If your SMTP server does not like the default ‘From: gitlab@gitlab.example.com
##! can change the ‘From’ with this setting.
gitlab_rails[‘gitlab_email_from’] = ‘abc@gmail.com’
gitlab_rails[‘gitlab_email_display_name’] = ‘Gitlab’
gitlab_rails[‘gitlab_email_reply_to’] = ‘abc@gmail.com’
gitlab_rails[‘gitlab_email_subject_suffix’] = ‘email’

gitlab_rails[‘incoming_email_enabled’] = true
gitlab_rails[‘incoming_email_address’] = “abc+%{key}@gmail.com
gitlab_rails[‘incoming_email_email’] = “abc@gmail.com
gitlab_rails[‘incoming_email_password’] = "xxxx

IMAP Settings

gitlab_rails[‘incoming_email_host’] = “imap.gmail.com
gitlab_rails[‘incoming_email_port’] = 993
gitlab_rails[‘incoming_email_ssl’] = true
gitlab_rails[‘incoming_email_start_tls’] = false"
gitlab_rails[‘incoming_email_mailbox_name’] = “inbox”
gitlab_rails[‘incoming_email_idle_timeout’] = 60
gitlab_rails[‘incoming_email_expunge_deleted’] = false

gitlab_rails[‘service_desk_email_enabled’] = true
gitlab_rails[‘service_desk_email_address’] = “abc@gmail.com
gitlab_rails[‘service_desk_email_email’] = “abc@gmail.com
gitlab_rails[‘service_desk_email_password’] = “xxxx”
gitlab_rails[‘service_desk_email_mailbox_name’] = “inbox”
gitlab_rails[‘service_desk_email_host’] = “imap.gmail.com
gitlab_rails[‘service_desk_email_port’] = 993
gitlab_rails[‘service_desk_email_ssl’] = true
gitlab_rails[‘service_desk_email_start_tls’] = false

and I try a click forget password it, but I didn’t recived any email incoming?
Do is my setting wrong?
please help

thanks a lot.

Someone who had a similar problem, check the thread they managed to get it working: Using Gmail to send email

This link from the docs also might help: SMTP settings | GitLab

I check on the /var/log/mail.log and I get the error.
is can help how to solve it? and is firewall need allow 587 port?
thanks.

postfix/smtp[19413]: connect to gmail-smtp-in.l.google.com[2404:6800:4003:c03::1b]:25: Network is unreachable
postfix/smtp[19413]: connect to gmail-smtp-in.l.google.com[74.125.24.27]:25: Connection timed out
postfix/smtp[19413]: connect to alt1.gmail-smtp-in.l.google.com[2607:f8b0:400e:c00::1b]:25: Network is unreachable
postfix/smtp[19413]: connect to alt1.gmail-smtp-in.l.google.com[173.194.202.26]:25: Connection timed out
postfix/smtp[19413]: connect to alt2.gmail-smtp-in.l.google.com[2607:f8b0:4023:c0b::1a]:25: Network is unreachable

You will have to make sure the firewall doesn’t block outbound ports for the ones you want to connect to. You will need to speak to your network admin for that, or if you are the admin for it, check your router/firewall and unblock the ports required for the particular communication method.

I check the firewall on ubuntu is inactive, it still need to allow the port ? I am using AWS Cloud to host the gitlab

Aws has a firewall between your instance and the internet make sure you unblocked inbound and outbound

I able to telnet smtp.gmail.com 587
but I not able to receive email?

Then check the links that I originally posted above: Not able to send out gmail smtp setting - #2 by iwalker because if it worked for them it must work for you.

this my setting, and I compare with others forum guide and the url link you send it, it same setting.
that I no idea why I cant receive email ?

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.gmail.com
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “abc@gmail.com
gitlab_rails[‘smtp_password’] = “xxxx”
gitlab_rails[‘smtp_domain’] = “smtp.gmail.com
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = false
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

Well since you have connection timed out from your VPS to port 25, it means you cannot send which means AWS is blocking outbound connections to port 25, which I asked for you to make sure the ports are not blocked. That means it’s not using port 587.

After you make config changes you must do gitlab-ctl reconfigure

ya, I been check it.
my region AWS is in SG, and SG is only care inbound only. there is nth with the AWS firewall

After you make config changes you must do gitlab-ctl reconfigure > yes I got do it everytime I change the setting and also been try reboot the server.

but is not working?

Security group should have inbound and outbound, so you must check outbound. And to check, from your instance do:

telnet 74.125.24.27 25

if doesn’t connect it means AWS is blocking you via security groups. Because that IP is google SMTP server from your info above.

I been find AWS support and they been review my Account.
here the result: state in the region ‘ap-southeast-1’. I can also see that your Route table, Network ACL and Security Group rules are configured for SMTP access.

that is no issue on AWS Security group blocking.
please advise gitlab part the email, I cant receive?

I have the same problem and it is not connected to Gmail, you can test with another email server to be sure, it still is not working.

To set GitLab up to receive email you’ll need to follow instructions here: Incoming email | GitLab

To have GitLab send outgoing email using Gmail, you’ll want to follow the docs here: SMTP settings | GitLab

If you encounter authentication errors with Gmail, ensure you have allowed less secure apps to access the account or try turning on 2-step validation and using an application password.

Please note that Gmail has strict sending limits that can impair functionality as your organization grows. We strongly recommend using a transactional service like SendGrid or Mailgun for teams using SMTP configuration.

If trying to send outbound email from a GitLab server using SMTP or another email provider, find the example for your email provider and follow the instructions here: SMTP settings | GitLab

You can test whether your configuration is working properly with this: SMTP settings | GitLab

There are also additional outbound email troubleshooting steps here: SMTP settings | GitLab

Note that if the connection is blocked at the network (by a network policy, ACL, custom DNS), this problem will need to be resolved at the network layer.

Logs about outbound emails will be captured in Sidekiq logs (/var/log/gitlab/sidekiq/current)

Please also note that GitLab uses a documentation-first methodology to ensure the documentation remains a complete, accurate, and trusted resource, and makes communicating about the use of GitLab more efficient. "New information that would be useful toward the future usage or troubleshooting of GitLab should not be written directly in a forum or other messaging system, but added to a documentation MR and then referenced, as described above."This is why linking to documentation is a standard response when helping others with GitLab.

1 Like