Ejemplo n.º 1
0
def send_message():

    now = datetime.now()
    dt_string = now.strftime("%d/%m/%Y %H:%M:%S")

    mms = MMSMessage()
    mms.headers['To'] = telephone + '/TYPE=PLMN'
    mms.headers['Message-Type'] = 'm-send-req'
    mms.headers['Subject'] = 'Image Alarm'

    slide1 = MMSMessagePage()
    slide1.add_image(tmp_image)
    slide1.add_text('Image Alarm.' + dt_string)

    mms.add_page(slide1)

    payload = mms.encode()

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((MMSC, 80))
    s.send("POST / HTTP/1.0\r\n")
    s.send("Content-Type: application/vnd.wap.mms-message\r\n")
    s.send("Content-Length: %d\r\n\r\n" % len(payload))

    s.sendall(payload)

    buf = StringIO()

    while True:
        data = s.recv(4096)
        if not data:
            break

        buf.write(data)

    s.close()
    data = buf.getvalue()
    buf.close()
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: anchen
# @Date:   2016-11-28 16:08:32
# @Last Modified by:   anchen
# @Last Modified time: 2016-11-28 16:08:50
from messaging.mms.message import MMSMessage, MMSMessagePage
mms = MMSMessage()
slide1 = MMSMessagePage()
slide1.add_text('hello world')
mms.add_page(slide1)
mms.to_file('mms_body.mms')