MMS support

A community member, kop316, has made great progress on MMS support. Until the various PRs get merged, here are some instructions to help get MMS working. You will download the sources and build mmsd-tng as the core MMS component and client part such aspurple-mm-sms to integrate with chatty.

Next we will download the sources for the two projects. I like to use a folder ~/Projects to store this git repos but it doesn't matter where you download the sources. First, mmsd-tng

mmsd

sudo apt install libmm-glib-dev meson git build-essential libglib2.0-dev libdbus-1-dev debhelper libebook1.2-dev
git clone https://gitlab.com/kop316/mmsd.git
cd mmsd
dpkg-buildpackage -us -uc
sudo dpkg -i ../mmsd-tng_{version}.deb

This will build the debian package for you. Since user systemd services don't automatically start, you need to run

systemctl --user start mmsd-tng

To start mmsd-tng after you install the package.

When you first run mmsd-tng, it autopopulates a settings file at $HOME/.mms/modemmanager/mms, but you can make it yourself:

[Modem Manager]
CarrierMMSC=http://mmsc.invalid
MMS_APN=apn.invalid
CarrierMMSProxy=NULL
AutoProcessOnConnection=true
AutoProcessSMSWAP=false

As a note, if you want to try using mmsd-tng without Chatty/Purple-mm-sms, you need to set “AutoProcessSMSWAP” to “true”. This allows mmsd-tng to automatically download and process MMS by itself.

We will need to edit the file $HOME/.mms/modemmanager/ModemManagerSettings. If you look up the APN settings for your carrier (in GNOME Settings, for example) you should be able to fill out the fields (last of the three is optional). Here is my example for Verizon USA:

CarrierMMSC=http://mms.vtext.com/servlets/mms
MMS_APN=vzwinternet

Another example for T-Mobile USA:

CarrierMMSC=http://mms.msg.eng.t-mobile.com/mms/wapenc
MMS_APN=fast.t-mobile.com

T-Mobile may alternatively use the mobilenet APN.

Here is one for telus

CarrierMMSC=http://aliasredirect.net/proxy/mmsc
MMS_APN=sp.telus.com
CarrierMMSProxy=74.49.0.18:80 

Note that you need the IP address/domain name AND the port for the MMS Proxy!

We need to now restart mmsd-tng since we changed the file:

systemctl --user restart mmsd-tng

Uou can also check the status of mmsd-tng with:

systemctl --user status mmsd-tng

If you want to try sending an MMS manually, You can use the python script at: https://source.puri.sm/kop316/mmsd/-/blob/master/test/send-message

python test/send-message --help

Shows you how to format the message. An example to send a group MMS:

python test/send-message "+10123456789,+12223334444" "" "cid-1,text/plain,/home/mobian/text.txt"

“cid-1” is the filename that the file is, “” is where you would put SMIL, “text/plain” is the MIMEtype of the object, and “/home/mobian/text.txt” is the absolute path of the file.

an example to send a picture:

python test/send-message "+10123456789" "" "cid-1,image/jpeg,/home/mobian/img.jpg"

Note that you can mix and match.

Clients

purple-mm-sms (chatty)

sudo apt install libpurple-dev meson libebook-contacts1.2-dev git
git clone https://source.puri.sm/kop316/purple-mm-sms.git
cd purple-mm-sms
git checkout mmsd
make
sudo make install

DIY python

An example of extracting the MMS file (example picture) follow the instructions below:

Clone the repository python-messaging:

> git clone https://www.github.com/davegermiquet/python-messaging.git
> cd python-messaging
> python setup.py install

create a python script that is like the following called extractmms.py

import sys
from messaging.mms.message import MMSMessage
path = sys.argv[1]
mms = MMSMessage.from_file(path)

print(mms.headers['From'])            
for data_part in mms.data_parts:
    datacontent=data_part.headers['Content-Type']
    if datacontent is not None:
        if 'Name' in datacontent[1]:
            print(datacontent[1])
            filename = datacontent[1]['Name']
            file_to_save = open(data_part.headers['Content-Type'][1]['Name'],'wb')
            file_to_save.write(data_part.data)
            file_to_save.close()

Look in the /home/mobian/.mms/modemmanager

You'll see files similar to this:

-rw-r--r-- 1 mobian mobian     35 Apr 25 15:04 EAF3794E6976ED658AE16353C998AC927FFE7778.status
-rw------- 1 mobian mobian  99943 Apr 25 15:04 EAF3794E6976ED658AE16353C998AC927FFE7778

Run the script above like this:

> python3 ./extractmms.py EAF3e794E6976ED658AE16353C998AC927FFE7778 

{'Name': '2c58dc7a3.png'}

> the picture is saved in the current folder named with the output from the script above

mms2mail

this tool convert mms to a mail stored in a mbox (unix standard mails storage). It can work as a daemon waiting for new MMS or convert already received MMS from mmsd storage folder

git clone https://gitea.geodock.egeo.net.eu.org/Public/mms2mail.git
cd mms2mail
sudo apt install python3-watchdog
pip install --user marrow-mailer
pip install --user python-messaging
mkdir -p ~/.local/bin
cp mms2mail ~/.local/bin

In order to activate the daemon :

mkdir -p ~/.config/systemd/user
cp mms2mail.service ~/.config/systemd/user/
systemctl --user daemon-reload 
systemctl --user enable mms2mail
systemctl --user start mms2mail

Mbox path and mail metadata can be customized with the configuration file mms2mail.ini (~/.mms/modemmanager/mms2mail.ini). Default value are used if not specified :

[mail]
mailbox = /var/mail/$USER  ; the mailbox where mms are appended
user = $USER               ; the user account specified as recipient
domain = $HOSTNAME         ; the domain part appended to phone number and user
attach_mms = false         ; whether to attach the full mms binary file

Others

You can also test a reference MMS implimentation at: https://source.puri.sm/kop316/chatty/-/tree/wip/sadiq/mm-account But this is not as stable as purple-mm-sms

More info

Please refer to these upstream links for any comments, hopefully they will get merged and this section can be removed soon.

https://source.puri.sm/kop316/purple-mm-sms

https://gitlab.com/kop316/mmsd

https://gitea.geodock.egeo.net.eu.org/Public/mms2mail

You can also see progress on MMS here: https://forum.pine64.org/showthread.php?tid=12491

You can optionally try and test out the full reference of MMS here:

https://source.puri.sm/kop316/chatty/-/tree/wip/sadiq/mm-account