-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug with not handling multiple buffers in the token reader prop…
…erly
- Loading branch information
1 parent
f0b6751
commit 2b455e6
Showing
13 changed files
with
227 additions
and
90 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
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 |
---|---|---|
|
@@ -13,13 +13,18 @@ public static void Send( | |
string password = null, | ||
MimeEntity body = null, | ||
int count = 1, | ||
bool useSsl = false) | ||
bool useSsl = false, | ||
int port = 9025) | ||
{ | ||
//var message = MimeMessage.Load(@"C:\Dev\Cain\Temp\message.eml"); | ||
var message = new MimeMessage(); | ||
|
||
message.From.Add(MailboxAddress.Parse(from ?? "[email protected]")); | ||
message.To.Add(MailboxAddress.Parse(to ?? "[email protected]")); | ||
//for (var i = 0; i < 400; i++) | ||
//{ | ||
// message.To.Add(MailboxAddress.Parse(to ?? $"testuser{i+1000}@longemaildomain1000001.com")); | ||
//} | ||
message.Subject = subject ?? "Hello"; | ||
message.Body = body ?? new TextPart("plain") | ||
{ | ||
|
@@ -28,7 +33,7 @@ public static void Send( | |
|
||
using var client = new SmtpClient(); | ||
|
||
client.Connect("localhost", 9025, useSsl); | ||
client.Connect("localhost", port, useSsl); | ||
|
||
if (user != null && password != null) | ||
{ | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Text; | ||
using SmtpServer.IO; | ||
using SmtpServer.Mail; | ||
using SmtpServer.Protocol; | ||
using SmtpServer.Text; | ||
|
@@ -19,6 +20,18 @@ static TokenReader CreateReader(string text) | |
return new TokenReader(new ReadOnlySequence<byte>(buffer, 0, buffer.Length)); | ||
} | ||
|
||
static TokenReader CreateReader(params byte[][] buffers) | ||
{ | ||
var segmentList = new ByteArraySegmentList(); | ||
|
||
foreach (var buffer in buffers) | ||
{ | ||
segmentList.Append(buffer); | ||
} | ||
|
||
return new TokenReader(segmentList.Build()); | ||
} | ||
|
||
static SmtpParser Parser => new SmtpParser(new SmtpCommandFactory()); | ||
|
||
[Fact] | ||
|
@@ -210,6 +223,9 @@ public void CanNotMakeMail(string input) | |
[InlineData("RCPT TO:<[email protected]>", "cain.osullivan", "gmail.com")] | ||
[InlineData(@"RCPT TO:<""Abc@def""@example.com>", "Abc@def", "example.com")] | ||
[InlineData("RCPT TO:<pelé@example.com>", "pelé", "example.com")] | ||
[InlineData("RCPT TO:<@example1.com:[email protected]>", "someone", "example.com")] | ||
[InlineData("RCPT TO:<@example1.com,@example2.com:[email protected]>", "someone", "example.com")] | ||
[InlineData("RCPT TO:<example/[email protected]>", "example/example", "example.com")] | ||
public void CanMakeRcpt(string input, string user, string host) | ||
{ | ||
// arrange | ||
|
@@ -225,6 +241,22 @@ public void CanMakeRcpt(string input, string user, string host) | |
Assert.Equal(host, ((RcptCommand)command).Address.Host); | ||
} | ||
|
||
[Theory] | ||
[InlineData("RCPT TO:<someone@@example.com>")] | ||
[InlineData("RCPT TO:<[email protected]>")] | ||
[InlineData("RCPT TO:<someone@-examplecom>")] | ||
public void CanNotMakeRcpt(string input) | ||
{ | ||
// arrange | ||
var reader = CreateReader(input); | ||
|
||
// act | ||
var result = Parser.TryMakeRcpt(ref reader, out _, out _); | ||
|
||
// assert | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void CanMakeProxyUnknown() | ||
{ | ||
|
@@ -389,6 +421,7 @@ public void CanMakeDomain() | |
[InlineData(@"[email protected]", "$A12345", "example.com")] | ||
[InlineData(@"!def!xyz%[email protected]", "!def!xyz%abc", "example.com")] | ||
[InlineData(@"[email protected]", "_somename", "example.com")] | ||
[InlineData(@"[email protected]", "somename", "127.0.0.1")] | ||
public void CanMakeMailbox(string email, string user, string host) | ||
{ | ||
// arrange | ||
|
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.