0

I have a job that picks up CSV files and sends them through an external mail service. Everything seems to be great, with one exception: I found that the windows style CRLF CSV files get mangled by the process and when I open them in a mail client, they have 3 0x0A characters at the end of each line.

I thought it would be easy to force base64 encoding of the files, but though it feels like s-nail should be a Ferrari from a programmability perspective, I can't find the gas pedal. Playing around with the mime settings, I can change the content type, but getting the payload to base 64 is just not happening.

echo "CSV files attached:" | s-nail -vv -Smimetypes-load-control -X'mimetype "application/octet-stream csv"'  -r [email protected] -s "Your CSV file" -a /data/review/fun.csv  -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="[email protected]" -S smtp-auth-password="yourmom" -S smtp="corgibutts.com:587" "[email protected]"

Does anyone have any idea how to make this happen?

2
  • mime-encoding base64 manpages.ubuntu.com/manpages/bionic/en/man1/s-nail.1.html
    – gapsf
    Commented Sep 29, 2022 at 3:02
  • I actually reached out to the author of s-nailx yesterday and there isn't a direct way to make this happen. I am going to explore some other options and will create an answer if I come up with something satisfactory.
    – lopass
    Commented Sep 30, 2022 at 14:17

1 Answer 1

0

I found that mac/unix line endings are not getting mangled, and have switched to that for those that can take it.

The author posted this to his mailing list in response to my question, the patch should be widely available about 3 months from now:

I today have implemented such a thing, but it will require v14.10 (hopefully around christmas).

base64 can be enforced by prefixing ! to a character set specification:

-a file[=[!]input-charset[#[!]output-charset]], --attach=.. (Send mode) Attach file, subject to tilde expansion (see Filename transformations and folder). In Compose mode the COMMAND ESCAPES ~@ and especially the scriptable ~^ provide alternatives for attaching files.

If file is not accessible but contains an equal-sign = a character set specification is split off. If only an input one is given it is fixated and no conversion is applied; an empty, or the special string hyphen-minus - means ttycharset. If an output one is given the conversion is performed on-the-fly, not considering file type nor content; however, empty string or hyphen-minus - enforce the default Character sets conversion (-a file, -a file=#, and -a file=-#- are identical), later applied after MIME- classifying file (HTML mail and MIME attachments, The mime.types files). Without ,+iconv, in features only this mode is available. The character set names may be prefixed with exclamation mark `!' to enforce base64 mime-encoding of the attachment.

His mailing list has the conversation, I don't see his latest reply there yet, but it should eventually be found here under the base64 encoding thread:

https://lists.sdaoden.eu/pipermail/s-mailx/2022-September/thread.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .