Sau một số lần thử và lỗi, tôi đã có thể thành công với sự sắp xếp sau.
Mã của tôi cũng tương tự như https://github.com/jstedfast/MailKit#sending-messages:
public void DoMail()
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Joey", "[email protected]"));
message.To.Add(new MailboxAddress("Alice", "[email protected]"));
message.Subject = "How you doin?";
message.Body = new TextPart("plain")
{
Text = @"Hey Alice,
What are you up to this weekend? Monica is throwing one of her parties on
Saturday and I was hoping you could make it.
Will you be my +1?
-- Joey
"
};
using (var client = new SmtpClient())
{
// For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("localhost", 25, false);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
// Note: only needed if the SMTP server requires authentication
//client.Authenticate("joey", "password");
client.Send(message);
client.Disconnect(true);
}
}
Đối với những người không thể truy cập imgur:
Domain Name: localhost
Nghe Interface: 0.0.0.0
Port Number: 25 (Mặc dù, trong trường hợp của Dalsier, Dalsier sẽ sử dụng 26)
Tiện ích mở rộng:
- [] SSL Implicit/TLS
- [x] 8BITMIME
- [] STARTTLS
- [] AUTH
- [x] SIZE
chỉ SSL/TLS: Không
Mật khẩu Chứng chỉ SSL/TLS: Không có
Kích thước Thông báo Tối đa (byte): 0
Nhận timeout (ms): 30000
Options:
- [] Yêu cầu xác thực
- [] Yêu cầu kết nối an toàn
- [] Chỉ cho phép xác thực văn bản rõ ràng qua kết nối an toàn
Có, tôi làm. Vấn đề chính là smtp4dev đang nghe ở cổng 26 và khi mã máy khách chạy smtp4dev dừng lại. Có vẻ như một ngoại lệ đã được ném vào bên trong mã smpt4dev. – Dalsier