Skip to content

Commit 3de8aa1

Browse files
authored
Merge pull request #2818 from Geod24/mlang/sendMailTImeout
feat(smtp): Allow to specify a timeout in sendMail
2 parents faf66b9 + d6a75f3 commit 3de8aa1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mail/vibe/mail/smtp.d

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import std.conv;
2020
import std.exception;
2121
import std.string;
2222

23+
import core.time;
24+
2325
@safe:
2426

2527

@@ -131,11 +133,11 @@ final class Mail {
131133
132134
Valid headers can be found at http://tools.ietf.org/html/rfc4021
133135
*/
134-
void sendMail(in SMTPClientSettings settings, Mail mail)
136+
void sendMail(in SMTPClientSettings settings, Mail mail, in Duration timeout = Duration.max())
135137
{
136138
TCPConnection raw_conn;
137139
try {
138-
raw_conn = connectTCP(settings.host, settings.port);
140+
raw_conn = connectTCP(settings.host, settings.port, null, 0, timeout);
139141
} catch(Exception e){
140142
throw new Exception("Failed to connect to SMTP server at "~settings.host~" port "
141143
~to!string(settings.port), e);

0 commit comments

Comments
 (0)