I'm able to correctly send smtp mails with PDF file attached from my C++ application. All the users can download the PDF attached file from their Mail client if they use their laptop or desktop pc, but some of them (about 4 out of ten users) are not able to download the attachments if they try to read their mail from their mobile phones (it happens mostly on iphones, but also on Android).
They receive the email text and they are able to see that there is an attached file, but then the file is not visible and they cannot open it.
It seems that the attached file is detected as a virus and it is blocked. If the user tried to open the same email by his mail client on his laptop, then the attachment is readable.
Is there any solution to solve this problem?
I have the same issue both with curl.exe and with smtpclient library.
This is the code I'm currently using based on smtpclient library.
SmtpClient smtp("smtp.gmail.com", 465, SmtpClient::SslConnection);
smtp.setUser("email@gmail.com");
smtp.setPassword("passwd");
// Create a MimeMessage
MimeMessage message;
EmailAddress sender("email@gmail.com", "name");
message.setSender(&sender);
EmailAddress to(email_recipient, ui->listautenti->currentText());
message.addRecipient(&to);
message.setSubject("example!");
// Add some text
MimeText text;
QString testo_della_mail = "Hello!";
text.setText(testo_della_mail);
message.addPart(&text);
// Now we create the attachment object
MimeAttachment attachment (new QFile(pdf_filename));
qDebug() << "Filename: " << pdf_filename;
// the file type can be setted. (by default is application/octet-stream)
attachment.setContentType("application/pdf");
// Now add it to message
message.addPart(&attachment);
msgBox.exec();
smtp.quit();