Code · 19 lines · 547 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19using MailSharp.SMTP.Extensions;
namespace MailSharp.SMTP.Session;

public partial class SmtpSession
{
	// Handle HELO command

	private async Task HandleHeloAsync(string[] parts, string line, CancellationToken ct)
	{
		if (state != SmtpState.Initial && state != SmtpState.TlsStarted)
		{
			await writer.WriteLineAsync(configuration["SmtpResponses:BadSequence"], ct);
			return;
		}
		state = SmtpState.HeloReceived;
		await writer.WriteLineAsync($"{configuration["SmtpResponses:Hello"]} {parts.ElementAtOrDefault(1) ?? "client"}", ct);
	}

}