I am trying to sign and send an email with MailSystem.NET.
The mail is sent with a signature but the receiving email clients won't accept the signature
Gmail error:
The sender does not match the digital signature.
Thunderbird error:
The signature does not match the message contents correctly
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);
}
How can I send mails with the correct signature?