经过一些尝试和错误,我能够通过以下安排取得成功。
我的代码类似于https://github.com/jstedfast/MailKit#sending-messages:
public void DoMail()
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Joey", "joey@friends.com"));
message.To.Add(new MailboxAddress("Alice", "alice@wonderland.com"));
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);
}
}
对于那些无法访问 imgur 的人:
域名:localhost
监听接口:0.0.0.0
端口号:25(尽管在 Dalsier 的情况下,Dalsier 将使用 26)
扩展名:
- [ ] 隐式 SSL/TLS
- [x] 8BITMIME
- []开始TLS
- [ ] 授权
- [x] 大小
SSL/TLS 证书:无
SSL/TLS 证书密码:无
最大消息大小(字节):0
接收超时(毫秒):30000
选项:
- [ ] 需要身份验证
- [ ] 需要安全连接
- [ ] 仅允许通过安全连接进行明文身份验证