0

我正在尝试使用 签名并发送电子邮件MailSystem.NET

邮件发送时带有签名,但接收电子邮件客户端不接受签名

邮箱错误:

发件人与数字签名不匹配。

雷鸟错误:

签名与邮件内容不匹配

static void Main(string[] args)
{
    var cert = new X509Certificate2(
      @"sender.pfx",
      "password",
      X509KeyStorageFlags.MachineKeySet);

    var signer = new CmsSigner(cert)
    {
        IncludeOption = X509IncludeOption.EndCertOnly
    };

    Message message = new Message();
    message.From.Email = "sender@gmail.com";
    message.To.Add("me@gmail.com");
    message.Subject = "Subject";
    message.BodyHtml.Text = "Html";
    message.BodyText.Text = "Plain Text";
    message.BuildMimePartTree();
    message.SmimeAttachSignatureBy(signer);

    SmtpClient.SendSsl(
        message,
        "smtp.gmail.com",
        465,
        "sender@gmail.com",
        "password",
        SaslMechanism.Login);
}

如何发送带有正确签名的邮件?

4

0 回答 0