@@ -24,9 +24,9 @@ int main(int argc, char *argv[])
2424 server.setUsername (QLatin1String (" your_email_address@host.com" ));
2525 server.setPassword (QLatin1String (" your_password" ));
2626
27- // Now we create a MimeMessage object. This is the email.
27+ // Now we create a SMimeMessage object. This is the email.
2828
29- MimeMessage message;
29+ SMimeMessage message;
3030
3131 EmailAddress sender (QLatin1String (" your_email_address@host.com" ), QLatin1String (" Your Name" ));
3232 message.setSender (sender);
@@ -53,34 +53,27 @@ int main(int argc, char *argv[])
5353 std::make_shared<MimeAttachment>(std::make_shared<QFile>(QLatin1String (" document.pdf" )));
5454 message.addPart (document);
5555
56- // Now create an SMime object
57-
58- auto smime = new SimpleMail::SMimePart (&message);
59-
6056 // Setup private and public key/certificate in PKCS#12 format
6157
62- smime-> setKeyFile (QLatin1String (" your_private_key.p12" ),
58+ message. setKeyFile (QLatin1String (" your_private_key.p12" ),
6359 QLatin1String (" your_private_key_password" ));
64- smime-> setPublicKey (QLatin1String (" recipient_public_key.cert" ));
60+ message. setPublicKey (QLatin1String (" recipient_public_key.cert" ));
6561
6662 // Sign the message. Only your private key is required.
67- // if(!smime-> sign()) {
63+ // if(!message. sign()) {
6864 // qDebug() << "Failed to create signed email";
69- // delete smime;
7065 // return -3;
7166 // }
7267
7368 // Encrypt the message. Only the recipient's public key/certificate is required.
74- // if(!smime-> encrypt()) {
69+ // if(!message. encrypt()) {
7570 // qDebug() << "Failed to create encrypted email";
76- // delete smime;
7771 // return -3;
7872 // }
7973
8074 // Sign and encrypt the message
81- if (!smime-> signAndEncrypt ()) {
75+ if (!message. signAndEncrypt ()) {
8276 qDebug () << " Failed to create signed and encrypted email" ;
83- delete smime;
8477 return -3 ;
8578 }
8679
0 commit comments