Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mail message attachment is getting Domain Key sign Exception #11

Open
vesnaveen opened this issue Jun 5, 2018 · 1 comment
Open

Comments

@vesnaveen
Copy link

Hello
When i send code without attachment domain key is sign easily but when i try with attachment its getting me error

Unable to Domain Key sign the message

My code is

using (MailMessage mailMessage = new MailMessage())
            {
                mailMessage.From = new MailAddress("mailMessage.From@gmail.com", "Soni");
                mailMessage.To.Add(new MailAddress("To@gmail.com"));                          
                mailMessage.Subject = "Reminder : Subject";
                mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
                mailMessage.Body = "body";
                mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
                mailMessage.IsBodyHtml = true;
                mailMessage.Attachments.Add(new Attachment(@"C:\TempFolder\file.txt"));
                try
                {
                    var domainKeySigner = new DomainKeySigner(privateKey, Domain, "email", new string[] { "From", "To", "Subject", "Feedback-ID" });
                    var dkimSigner = new DkimSigner(privateKey, Domain, "email", new string[] { "From", "To", "Subject", "Feedback-ID" });
                    mailMessage.DomainKeySign(domainKeySigner);
                    mailMessage.DkimSign(dkimSigner);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                try
                {
                    client.Send(mailMessage);
                    Console.WriteLine("Success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

mail will be send but dkim not been proper verfiyed . What's the issue. Please get me solution

Thanks
Naveen Soni

@jstedfast
Copy link

For anyone having this issue, I would recommend using MimeKit's DKIM support instead.

If you also need SMTP functionality to send the resulting message, you can use MimeKit with MailKit (since you won't be able to use MimeKit with System.Net.Mail.SmtpClient).

Hopefully Damien doesn't mind me making this suggestion since it appears that he is no longer maintaining this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants