Why can we not send base64 data as attachment without either uf8 encoding it, or breaking html body?!
- Dominant language
- Swift
- Stars
- 290
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
```
let base64Encoded = signedData.base64EncodedString()
let gpgAttachment = Attachment(
data: Data(base64Encoded.utf8),
mime: "application/octet-stream", // or "application/octet-stream"
name: "\(title).pdf.gpg",
inline: false,
additionalHeaders: [
"Content-Transfer-Encoding": "base64"
]
)
let mail = Mail(
from: from,
to: [toUser],
subject: emailSubject,
text: "Please use a HTML ready Mail Client to view the email.",
attachments: [
Attachment(
htmlContent: htmlContent,
additionalHeaders: ["Content-Type": "text/html; charset=utf-8"]
),
gpgAttachment
]
)
```
The above works:
- HTML in email will not be broken
- file will be attached
BUT:
since file is a SIGNED file (thus a `.gpg` file), the above code will BREAK the signature as we encode it to `utf8` and that messes the signature up
Thus:
```
let gpgAttachment = Attachment(
data: signedData,
mime: "application/octet-stream", // or "application/octet-stream"
name: "\(title).pdf.gpg",
inline: false,
additionalHeaders: [
"Content-Transfer-Encoding": "base64"
]
)
```
File will now validate correctly (PGP signature valid) but this will mess up the HTML part of the mail rendering it gibberish like `v�-蕳《ia秈q歒���m��鹈7⒏?走}�etc etc`
There must be something I miss.
Contributor guide
Assessment
This issue has not been assessed yet.