Need Help to Configure SMTP in GitLab

Good Day All,

I am new here at GitLab.
I installed GitLab in my Linux LTS 22.04.
I am facing issue regarding configure SMTP. I already configure SMTP as per guide but mail not sent. Below is my configuration and error of I am getting when I send test mail, Please help me regarding this. Thank you in advance.

My Configuration,

{:authentication=>:login,
:user_name=>“My Email”,
:password=>“Email Password”,
:address=>“smtp.office365.com”,
:port=>587,
:domain=>“My Domain”,
:enable_starttls_auto=>true,
:openssl_verify_mode=>“peer”,
:ca_path=>“/etc/ssl/certs”,
:ca_file=>“/etc/ssl/certs/ca-certificates.crt”,
:open_timeout=>30,
:read_timeout=>60}

Error I am getting,

Delivered mail 6672d26713634_9cc562ee07524@spl-git-server.mail (120201.6ms)
/opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:1214:in __connect_nonblock': Network is unreachable - connect(2) for [2603:1016:401:2c11::2]:587 (Errno::ENETUNREACH) from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:1214:in connect_nonblock’
from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:56:in connect_internal' from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:137:in connect’
from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:227:in each' from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:227:in foreach’
from /opt/gitlab/embedded/lib/ruby/3.1.0/socket.rb:632:in tcp' from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:643:in tcp_socket’
from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:656:in do_start' from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in start’
from /opt/gitlab/embedded/service/gitlab-rails/config/initializers/mail_starttls_patch.rb:53:in start_smtp_session' from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:indeliver!’
from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/mail-2.8.1/lib/mail/message.rb:2145:in do_delivery' from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/mail-2.8.1/lib/mail/message.rb:253:in block in deliver’
from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/actionmailer-7.0.8.1/lib/action_mailer/base.rb:588:in block in deliver_mail' from /opt/gitlab/embedded/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8.1/lib/active_support/notifications.rb:206:in block in instrument’
… 20 levels…

Microsoft doesn’t support authentication by username/password now. You have to use oauth instead or Graph API.

If you are unable to do that, it would be easier to just install something like postfix, ensure your SPF record allows that server for sending emails from your domain, and then it will send like a normal SMTP server to another SMTP server over port 25.

Thank you for your reply,

Problem is sorted.
I used gmail instead of microsoft.
Thanks again.

1 Like