Skip to content

Commit d6a75f3

Browse files
committed
feat(smtp): Allow to specify a timeout in sendMail
Otherwise a program may get stuck indefinitely.
1 parent faf66b9 commit d6a75f3

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)