How to send S/MIME encrypted mails from iOS with attachment?

I can tell you why this happens but not give you a solution. To me this is a bug, when you 'mail' from within photos or whatever other app, using the modal compose window (the one that pops up from the bottom of the screen) you are using a MFMailComposeViewController class, this is effectively a baby version of mail that pops up and composes mail for you, then redirects this to the mail app.

Something is broken in between that's causing your issue.

Bottom line the MFMailComposeViewController (https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html) is not the full mail client and thus it's lacking the encryption piece.