DKIM failed using Aspose.Email

Hi Aspose Team ,
I am using aspose.email 19.8 latest version .If i use only plain text then dkim passed but when we use html body then it gives an error dkim fail with message dkim=fail(body hash did not verify).
i have enable same MailMessage.IsBodyHtml = true;
please suggest .
Thanks,
Jitendra

@jitendra1,

Can you please share source file along with sample code so that we may further investigate to help you out.

try
{
MailMessage MailMessage = new MailMessage();

        #region Sender (作為主要退信address)
        MailMessage.Sender = "support@dajinsoft.com";
        MailMessage.Sender.DisplayName = "達璟資訊 Dajinsoft";
        #endregion

        #region From
        MailMessage.From = "crm@dajinsoft.com";
        MailMessage.From.DisplayName = "達璟資訊";
        #endregion

        #region To
        MailMessage.To.Add("carlossy.l@gmail.com");
        MailMessage.To.Add("carlossy.l@hotmail.com");
        #endregion

        #region Content
        MailMessage.Subject = "諮詢回覆通知ABC";
        StringBuilder sb = new StringBuilder();
        StreamReader sr = new StreamReader(@"C:\EMAIL_DEMO.html", Encoding.UTF8);
        sb.Append(sr.ReadToEnd());
        MailMessage.HtmlBody = sb.ToString();
        MailMessage.IsBodyHtml = true;
        #endregion

        MailMessage.BodyEncoding = Encoding.UTF8;
        MailMessage.SubjectEncoding = Encoding.UTF8;
        MailMessage.PreferredTextEncoding = Encoding.UTF8;

        MailMessage = SignedDKIM(MailMessage);
        //MailMessage.Save(FilePath, SaveOptions.DefaultEml);


        SmtpClient client = new SmtpClient();
        client.Host = "exmail.dajinsoft.com";
        client.Username = "username";
        client.Password = "password";
        client.Port = 25;
        //client.UseAuthentication = false;
        //client.SupportedEncryption = Aspose.Email.Clients.Base.EncryptionProtocols.Ssl2;
        client.SecurityOptions = SecurityOptions.None;
        client.Send(MailMessage);
        
    }
    catch (Exception)
    {                
        throw;
    }
}

private MailMessage SignedDKIM(MailMessage mailMessage)
{
    //私鑰
    string privateKeyFile = @"C:\Develop\Dajin\Product\CRM\CommonFiles\Settings\Email.Key.pem";

    //加密演算法, 預設為 rsa
    RSACryptoServiceProvider rsa = PemReader.GetPrivateKey(privateKeyFile);

    //加簽內容
    string selector = "s1233225";
    string domain = "dajinsoft.com";
    DKIMSignatureInfo signInfo = new DKIMSignatureInfo(selector, domain);
    signInfo.HashAlgorithm = DKIMHashAlgorithm.RSASha256;
    signInfo.BodyCanonicalization = CanonicalizationType.Relaxed;
    signInfo.HeaderCanonicalization = CanonicalizationType.Relaxed;
    signInfo.Headers.Add("From");
    //signInfo.Headers.Add("Subject");

    MailMessage signedMsg = mailMessage.DKIMSign(rsa, signInfo);

    return signedMsg;
}

We are using same code from your portal-Signing email with DKIM has issue when opened in Gmail (C# .NET) - #15 by carlos_liu

@jitendra1,

The thread that you have referred has been fixed in Aspose.Email for .NET 19.8. As you have shared that you are still able to reproduce the issue. I request you to please share the working sample project along with source HTML file and test account that we may try on our end to verify and resolve the issue.

Dkim_mail.zip (3.4 MB)
Please find zip file as source code.

@jitendra1,

Thank you for sharing the sample project. I have tried using that on my end and getting exception on getting private key file as shown in Figure below. As requested earlier, can you please provide a working sample project along with test account access that is reproducing the issue on your end.

I have also observed your in project that you have been using Aspose.Email for .NET 19.3. Whereas, I suggested you to please use Aspose.Email for .NET 19.8 on your end.

image.png (21.7 KB)

As I seen that i am using latest version 19.8 of Aspose.Email.Some security reason I can’t provide you private key.Can you please test the scenario.

@jitendra1,

I have created an issue with ID EMAILNET-39571 as investigation to further investigate the issue on our end. We will share feedback with you as soon as the issue will be fixed.

Hi,

I am looking for solution for this issue.we did not receive any feedback from your side.
Please help us for the solution ASAP.

Thanks,
Jitendra

@jitendra1,

I have observed your comments and like to share that the issue has just recently been added in our issue tracking system and is pending for investigation in issues queue. We request for your patience till the time the issue gets scheduled on its due turn and feedback is shared.

Hi Aspose Team,

As I seeing EMAILNET-39571 is resolved.Is it released or not?
If released then what is change in code. Please suggest me.

Issues Status

EMAILNET-39571 ---- Status : Resolved

Thanks,
Jitendra

@jitendra1,

I like to inform that this issue has been resolved in 19.9 which will be release soon.

1 Like

can you please tell expected date by when this will be release?

@awadhesh_jha,

I request you to please try using latest Aspose.Email for .NET version on your end and share your feedback if there is still an issue.

hey !
this is Aspose Slides for .NET 19.9 link not for email.
please provide us to Aspose.Email for .Net link

@awadhesh_jha,

I like to inform that Aspose.Email 19.8 will be available before the end of September. I request for your patience.

Thanks for your response.

Hi Aspose Team,

Is this release can you confirm verifying signature with Attachments and cc’d will work fine ?

@jitendra1,

Yes, this issue will be resolved in 19.9. We will share good news with you soon. I request for your patience.