当 DKIM 使用 Mailkit 和 Mimekit 签署标头时,我看到一个奇怪的问题,Gmail 报告错误“dkim=neutral(正文哈希未验证)”。
我在这里做错了吗?请在下面找到我的代码和屏幕截图
附上实际收到的邮件。
string ReturnName = "DMC12";
string FromDomain = "backtothefuture.net";
string FromEmail = "marty@" + FromDomain;
string FromName = "Marty McFly";
string SenderName = "Marty McFly";
string ToEmail = "George.mcfly.1960@gmail.com";
string MailServer = "DMC12.large.timemachine.com";
string TextBody = @"If you put your mind to it, you can accomplish anything. One other thing. If you guys ever have kids, and one of them, when he's eight years old, accidentally sets fire to the living …Run Code Online (Sandbox Code Playgroud) I'm trying to send an email with Gmail account. I was able to send emails with yahoo, however, it doesn't work anymore, for some unknown reason. Which i posted a question about that as well, but not response.
In this instance, i'm trying to connect to a gmail account so that I can send emails, but with no luck, it fails after the Connect.
It connects successfully but doesn't authenticate at all, although I have the right credentials.
This is …
如何使用 MailKit 从内存流发送带有附件的电子邮件?目前,我正在使用常规 SMTP 发送并使用以下代码附加文件,但找不到任何正确的示例来使用 MailKit 包发送它。我已经阅读了这两篇文档,但找不到合适的解决方案。 http://www.mimekit.net/docs/html/M_MimeKit_AttachmentCollection_Add_6.htm
using System.Net.Mail;
MemoryStream memoryStream = new MemoryStream(bytes);
message.Attachments.Add(new Attachment(memoryStream, "Receipt.pdf", MediaTypeNames.Application.Pdf));
Run Code Online (Sandbox Code Playgroud)
这是我的 MailKit 电子邮件代码:
#region MailKit
string fromEmail = GlobalVariable.FromEmail;
string fromEmailPwd = "";//add sender password
var email = new MimeKit.MimeMessage();
email.From.Add(new MimeKit.MailboxAddress("Sender", fromEmail));
email.To.Add(new MimeKit.MailboxAddress("receiver", "receiver@gmail.com"));
var emailBody = new MimeKit.BodyBuilder
{
HtmlBody = htmlString
};
email.Subject = "test Booking";
email.Body = emailBody.ToMessageBody();
//bytes is parameter.
//MemoryStream memoryStream = new MemoryStream(bytes);
//message.Attachments.Add(new Attachment(memoryStream, "Receipt.pdf", MediaTypeNames.Application.Pdf));
using (var smtp = new MailKit.Net.Smtp.SmtpClient()) …Run Code Online (Sandbox Code Playgroud) 首先,对于一些上下文:我正在使用 .NetCore 开发带有 Identity 的 API。一切都在 Docker 内部的云服务器上。创建用户后,将使用邮件包和 Web 邮件服务器通过 Plesk(托管在同一台计算机上)向新用户发送电子邮件。docker 通过 Apache 使用 ProxyPass 进行重定向,从子域到本地主机上的端口进行访问
通过 JetBrain 的 Rider 进行调试时一切正常,但无法处理服务器上 Docker 中的电子邮件。
这是堆栈:
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable
at System.Net.Dns.InternalGetHostByName(String hostName)
at System.Net.Dns.ResolveCallback(Object context)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
at System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
at System.Net.Dns.<>c.<GetHostAddressesAsync>b__25_1(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
Run Code Online (Sandbox Code Playgroud)
我还没有尝试在另一台 Linux 机器上运行 docker 来测试。我目前的猜测之一是 SSL 证书有问题,但我认为这不会导致 DNS …
我按照本指南尝试在电子邮件中嵌入 2 个图像,这是我用 C# 编写的控制台应用程序代码: ExecuteSendMailEx 过程:
public void ExecuteSendMailEx(AccesBase accesBase, string From, string Subjet, bool Format, string EmailLogoHeader, string EmailLogoFooter, string ReplyTo, string ReturnPath, string BodyHtml, string BodyText, string Destinataire, string IdLangage, string CopieCachee, string PJ, string SMTP, string SMTPPORT, string SMTPLOGIN, string SMTPPWD, ref int RTN)
{
try
{
Log.Information("ENVOI_Constructor ExecuteSendMailEx has begun");
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse(From));
email.To.Add(MailboxAddress.Parse(Destinataire));
email.ReplyTo.Add(MailboxAddress.Parse(ReplyTo));
if (!string.IsNullOrEmpty(CopieCachee))
email.Bcc.Add(MailboxAddress.Parse(CopieCachee));
email.Subject = Subjet;
email.Sender = (MailboxAddress.Parse(SMTPLOGIN));
var currentDirectory = Directory.GetCurrentDirectory();
var parentDirectory …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MailKit库开发ImapClient.
如何从Gmail帐户中永久删除邮件,而不是将其移至"废纸篓"文件夹?
我的代码是:
using (ImapClient client = new ImapClient())
{
// Connect to the server and authentication and then
var inbox = client.Inbox;
inbox.Open(FolderAccess.ReadOnly);
int messageCount = inbox.Count - 1;
for (int i = messageCount; i > 0 ; i--)
{
var visitor = new HtmlPreviewVisitor();
MimeMessage message = inbox.GetMessage(i);
message.Accept(visitor);
// how can get uid for this message
}
}
Run Code Online (Sandbox Code Playgroud)
我想拯救你的魔杖.怎么能得到消息的uid?
MimeMessage message =inbox.GetMessage(UniqueId.Parse(uid));
Run Code Online (Sandbox Code Playgroud) 希望我能以一种简单的方式解释我的要求:
在.Net Core中,我们可以.cshtml在使用后发送模型数据后显示视图View(FileName, Model).
有没有办法Model将.cshtml文件发送到文件,以便我可以通过电子邮件发送附件,而不是显示生成的视图Mailkit
我正在构建一个简单的.net MailKit IMAP客户端。而不是一次又一次地从IMAP服务器提取电子邮件,是否可以将整个MailKit MIME消息(包括附件在内的完整消息)存储为字节数组?如果是这样,怎么办?
然后,我可以将其写入MySql或文件中,然后将其重新用于测试代码更改。
mailkit ×10
c# ×7
.net ×2
email ×2
smtp ×2
.net-core ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
console ×1
dkim ×1
docker ×1
gmail ×1
gmail-imap ×1
imap ×1
mimekit ×1
razor ×1
smtp-auth ×1
smtpclient ×1