forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/2.0.0] Port SmtpClient fixes to 2.0 (dotnet#24727)
* Fix null ref exception when Dispose'ing SmtpClient (dotnet#24521) If SmtpClient is disposed after a failed send and no successful sends, it attempts to call Close on a null NetworkStream field. * Fix hang when SmtpClient.SendAsync fails to connect (dotnet#24536) If Send{Mail}Async fails to connect, an exception gets thrown/eaten, and the completion callback is never invoked / the returned Task is never completed.
- Loading branch information
1 parent
6ae66ab
commit f997049
Showing
2 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,6 +270,24 @@ public void TestTimeout(int value) | |
Assert.Equal(value, Smtp.Timeout); | ||
} | ||
|
||
[Fact] | ||
public void Send_ServerDoesntExist_Throws() | ||
{ | ||
using (var smtp = new SmtpClient(Guid.NewGuid().ToString("N"))) | ||
{ | ||
Assert.Throws<SmtpException>(() => smtp.Send("[email protected]", "[email protected]", "subject", "body")); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task SendAsync_ServerDoesntExist_Throws() | ||
{ | ||
using (var smtp = new SmtpClient(Guid.NewGuid().ToString("N"))) | ||
{ | ||
await Assert.ThrowsAsync<SmtpException>(() => smtp.SendMailAsync("[email protected]", "[email protected]", "subject", "body")); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestMailDelivery() | ||
{ | ||
|