Skip to content

Commit fb4fe97

Browse files
committed
[Mailer] fixed SMTP support when a message cannot be sent
1 parent 5b7dc58 commit fb4fe97

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Smtp/SmtpTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ public function send(RawMessage $message, SmtpEnvelope $envelope = null): ?SentM
111111
$this->start();
112112
}
113113

114-
$message = parent::send($message, $envelope);
114+
try {
115+
$message = parent::send($message, $envelope);
116+
} catch (TransportExceptionInterface $e) {
117+
$this->executeCommand("RSET\r\n", [250]);
118+
119+
throw $e;
120+
}
115121

116122
$this->checkRestartThreshold();
117123

SmtpTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ public function send(RawMessage $message, SmtpEnvelope $envelope = null): ?SentM
111111
$this->start();
112112
}
113113

114-
$message = parent::send($message, $envelope);
114+
try {
115+
$message = parent::send($message, $envelope);
116+
} catch (TransportExceptionInterface $e) {
117+
$this->executeCommand("RSET\r\n", [250]);
118+
119+
throw $e;
120+
}
115121

116122
$this->checkRestartThreshold();
117123

Transport/Smtp/SmtpTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ public function send(RawMessage $message, SmtpEnvelope $envelope = null): ?SentM
111111
$this->start();
112112
}
113113

114-
$message = parent::send($message, $envelope);
114+
try {
115+
$message = parent::send($message, $envelope);
116+
} catch (TransportExceptionInterface $e) {
117+
$this->executeCommand("RSET\r\n", [250]);
118+
119+
throw $e;
120+
}
115121

116122
$this->checkRestartThreshold();
117123

0 commit comments

Comments
 (0)