Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise default SMTP timeout from 10 to 30 sec #39638

Closed
wants to merge 2 commits into from
Closed

Conversation

solracsf
Copy link
Member

@solracsf solracsf commented Jul 31, 2023

Summary

With some hosted STMP services, like smtp.office365.com they have some security mesures like bruteforce protection, and SMTP response can take more than (default) 10s between SSL handshake, auth, EHLO, etc.. In the logs this can lead to things like:

Error: stream_socket_enable_crypto(): SSL: Handshake timed out at /3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php#94

Swift_TransportException: Failed to authenticate on SMTP server with username "no-reply@nextcloud" using 1 possible authenticators.
Authenticator LOGIN returned Expected response code 250 but got code "235", with message "235 2.7.0 Authentication successful ".

This PR raises the default from 10 to 30 seconds.

Other changes here are just small code optimizations.

Checklist

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf added the 3. to review Waiting for reviews label Jul 31, 2023
@solracsf solracsf added this to the Nextcloud 28 milestone Jul 31, 2023
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
This was referenced Nov 14, 2023
@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
@skjnldsv skjnldsv requested review from ChristophWurst, szaimen, come-nc, a team, ArtificialOwl and sorbaugh and removed request for a team and ChristophWurst February 24, 2024 16:29
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
/** @var SocketStream $stream */
$stream = $transport->getStream();
/** @psalm-suppress InternalMethod */
$stream->setTimeout($this->config->getSystemValueInt('mail_smtptimeout', 10));
$stream->setTimeout($this->config->getSystemValueInt('mail_smtptimeout', 30));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the downside is that server that are not reachable will make the PHP process run longer than 30 seconds and cause a timeout

I'm on the fence here. we could also improve our documentation about increasing the timeout if there are servers where this is necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would also vote against it, timeout can already be set in the configuration and 10 seconds looks like a sane default.

@solracsf solracsf closed this Feb 26, 2024
@solracsf solracsf deleted the smtpTimeout30s branch February 26, 2024 11:50
@skjnldsv skjnldsv added enhancement feature: emails and removed 3. to review Waiting for reviews labels Feb 26, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 29 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants