0

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();
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Marcus Barnet
  • 2,083
  • 6
  • 28
  • 36
  • 1
    This is not really _your_ problem. You need to find out more about how your users' machines are configured. – Paul Sanders Jun 13 '21 at 21:34
  • 1
    Most likely just an overzealous antivirus/antimalware is installed on the affected clients. Most AVs/AMs will scan incoming email for malicious content. Recently, the AV I've been using for years has starred quarantining emails I know are innocent, I don't know why. – Remy Lebeau Jun 13 '21 at 23:10
  • But this is strange because they correctly receive the attachment if I send it through a normal mail sent by my mail client (I use Outlook or Airmail). They have problems only when I send the email with the attached file by using my C++ application. – Marcus Barnet Jun 14 '21 at 06:16
  • If I forward the email with the not visible pdf file to another email address then the attached file is visible again!! This is crazy! – Marcus Barnet Jun 14 '21 at 10:24

0 Answers0