• Re: Error when sending via Gmail from mpack

    From Jim Jackson@3:770/3 to Adrian on Tue Aug 16 09:30:22 2022
    On 2022-08-15, Adrian <bulleid@ku.gro.lioff> wrote:
    In message <QG+GIsU6iX+iFwxT@ku.gro.lloiff>, Adrian
    <bulleid@ku.gro.lioff> writes
    No, I haven't tried it, the thought hadn't occurred to me. I'll give
    it a go and report back.


    Hmm, well it sort of works.

    I can run mpack against the image that I want to send, and it creates an output file, but there is no addressing information with it :

    Message-ID: <10695.1660569414@pi2>
    Mime-Version: 1.0
    Subject: Front Door Alert
    Content-Type: multipart/mixed; boundary="-"

    This is a MIME encoded message. Decode it with "munpack"
    or any other MIME reading software. Mpack/munpack is available
    via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
    ---
    Content-Type: image/jpeg; name="image_202208151316.jpg" Content-Transfer-Encoding: base64
    Content-Disposition: inline; filename="image_202208151316.jpg"
    Content-MD5: 7YS3HQC2BvZxh142Go44Xg==

    and then into the encoded version of the image.

    Mpack won't allow me to add a destination address if the output is to a
    file (rather than as an email).

    I can then cat that into msmtp (after some header information), and the
    email duly appears. So far, so good. The problem now is that I don't
    have a jpg file (as such), I've got a base64 encoding of it, and my
    (Android) phone won't convert that back into a usable JPG (one that I
    can look at),


    Ok you can add the From: and To: to the file created by mpack before
    sending with msmtp.

    When using mpack use the '-c' option to specify the mime type of the
    file being packed.

    -c image/jpeg

    For other files you can probably use

    xdg-mime query filetype /tmp/tmpfile

    to find to right mime type to specify. Dunno why mpack changes it
    behaviour between the 2 cases.

    It should be easy to script this.

    cheers
    Jim

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Eli the Bearded@3:770/3 to bulleid@ffoil.org.uk on Fri Aug 19 17:48:40 2022
    In comp.sys.raspberry-pi, Adrian <bulleid@ffoil.org.uk> wrote:
    Eli the Bearded <*@eli.users.panix.com> writes
    I just did some playing with mpack myself. The output is compliant with
    mid-90s RFCs (eg RFC-2046), I am not up on more modern standards, but it
    is very quirky looking compared to modern MIME encoding.

    mpack -c image/jpeg -d /dev/null -o output_file <file>

    gives :

    Message-ID: <14058.1660767984@pi2>
    Mime-Version: 1.0
    Subject:
    Content-Type: multipart/mixed; boundary="-"

    This is a MIME encoded message. Decode it with "munpack"
    or any other MIME reading software. Mpack/munpack is available
    via anonymous FTP in ftp.andrew.cmu.edu:pub/mpack/
    ---


    ---
    Content-Type: image/jpeg; name="image_202208172025.jpg" Content-Transfer-Encoding: base64
    Content-Disposition: inline; filename="image_202208172025.jpg"
    Content-MD5: NhPEg4pgYEkaTbtZnOkNsg==

    I'm assuming that the set of blank lines is the area for the
    description.

    You would be 100% correct. And the lack of headers on the description
    part is a big "quriky" output.

    BTW, if you just need a message composed with a single file of a known
    type and no other frills, that's really easy to do via shell script. The benefits of mpack are slim for that small use case.

    You print your headers, with some particular mime details, you include
    your base64 encoded image, and done. This is a super-bare-bones untested version that has no multipart, just jpeg:

    #!/bin/sh
    file="$1"
    if [ ! -f "$file" ] ; then
    echo 'Usage:'
    echo ' echo "To: foo@bar" > output'
    echo ' echo "From: bar@foo" >> output'
    echo ' echo "Subject: qux" >> output'
    echo ' composer jpegfile >> output'
    echo ''
    echo 'Then send with eg, sendmail -oi < output'
    exit 2
    fi

    # simple JPEG as body email
    echo 'Mime-Version: 1.0
    echo 'Content-Type: image/jpeg; name="'"$file"'"'
    echo 'Content-Transfer-Encoding: base64'
    echo 'Content-Disposition: inline; filename="'"$file"'"'
    echo ''
    base64 "$file"
    echo ''

    exit

    And this is a multipart example:

    #!/bin/sh
    file="$1"
    desc="$2"
    if [ ! -f "$desc" ] ; then
    echo 'Usage:'
    echo ' echo "To: foo@bar" > output'
    echo ' echo "From: bar@foo" >> output'
    echo ' echo "Subject: qux" >> output'
    echo ' multicomposer jpegfile description.txt >> output'
    echo ''
    echo 'Then send with eg, sendmail -oi < output'
    exit 2
    fi

    # simple multipart with text and jpeg. The use of = and - means
    # that the boundary string cannot occur in base64 or quoted
    # printable content
    boundary=--==randomness--$$==--

    echo 'Mime-Version: 1.0
    echo 'Content-Type: multipart/mixed; boundary="'$boundary'"'
    echo ''

    # each part starts with named boundary plus two hyphens
    echo "--$boundary"
    echo 'Content-Type: text/plain; charset="UTF-8"'
    # echo 'Content-Transfer-Encoding: quoted-printable;
    echo ''
    # if you have it, consider "mmencode -q < $desc" to quoted-printable
    # encode body
    cat $desc
    echo ''

    echo "--$boundary"
    echo 'Content-Type: image/jpeg; name="'"$file"'"'
    echo 'Content-Transfer-Encoding: base64'
    echo 'Content-Disposition: inline; filename="'"$file"'"'
    echo ''
    base64 "$file"

    # final boundary is indicated with extra hyphens at end
    echo "--$boundary--"
    echo ''

    exit

    My mail software has a set of scripts evolved from Rnmail (in the rn/trn package) that does roughly this but includes a "vi $outfile" step before sendmail is used.

    Elijah
    ------
    added 'rnmail' as a command to the mailx he uses

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Adrian@3:770/3 to bulleid@ku.gro.lioff on Sat Sep 3 13:42:18 2022
    In message <XHU22bPwoNDjFw8H@ku.gro.lloiff>, Adrian
    <bulleid@ku.gro.lioff> writes
    Switching to the multipart address script, rather than the simple
    version it all appears to work. The email appears on my mail hosts
    server, I can see an attachment (but not read it, this shouldn't be a >problem, I rarely read emails directly on the server). The mail gets
    copied to my Gmail account (where I can read it, and view the
    attachment), and it also forwards to my home PC (which I'm not bothered >about, but can live with), and I can view the attachment there as well.


    I've had another session with this, and further improved it. I tried
    cat'ing the file (consisting of the headers, body, attachment etc.
    generated by Eli's script) into msmtp :

    cat /tmp/output | msmtp $addressee

    and that works. My msmtp configuration is set up to use a Gmail account
    to send from, so that avoids having to do anything fancy on my mail
    hosts server, and I don't get an unwanted copy of the email sent to me@mydomain. Basically I'm back to where I was earlier in the year
    before Gmail made their changes.

    Adrian
    --
    To Reply :
    replace "bulleid" with "adrian" - all mail to bulleid is rejected
    Sorry for the rigmarole, If I want spam, I'll go to the shops
    Every time someone says "I don't believe in trolls", another one dies.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)