Created
July 20, 2015 13:58
-
-
Save SAPikachu/caa7da4925d1872d95db to your computer and use it in GitHub Desktop.
Test code for sending mail to change event in Google Calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
# [email protected] is the organizer, [email protected] is controlled by our app and wants to update the event | |
# Message body is modified from the mail sent by Google Calendar | |
body = """Date: Fri, 17 Jul 2015 13:23:53 +0000 | |
Subject: Updated: RFC2446 Test @ Tue Jul 21, 2015 5pm - 6pm ([email protected]) | |
From: [email protected] | |
To: Joe Hu <[email protected]>, [email protected] | |
Content-Type: multipart/mixed; boundary=047d7bf0e8e4de0bd8051b121546 | |
--047d7bf0e8e4de0bd8051b121546 | |
Content-Type: multipart/alternative; boundary=047d7bf0e8e4de0bc9051b121544 | |
--047d7bf0e8e4de0bc9051b121544 | |
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes | |
Test custom request | |
--047d7bf0e8e4de0bc9051b121544 | |
Content-Type: text/calendar; charset=UTF-8; method=REQUEST | |
Content-Transfer-Encoding: 7bit | |
BEGIN:VCALENDAR | |
PRODID:-//Google Inc//Google Calendar 70.9054//EN | |
VERSION:2.0 | |
CALSCALE:GREGORIAN | |
METHOD:REQUEST | |
BEGIN:VEVENT | |
DTSTART:20150721T090000Z | |
DTEND:20150721T100000Z | |
DTSTAMP:20150717T134825Z | |
ORGANIZER;CN=Joe Hu:mailto:[email protected] | |
UID:[email protected] | |
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= | |
TRUE;[email protected];X-NUM-GUESTS=0:mailto:[email protected] | |
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= | |
TRUE;[email protected];X-NUM-GUESTS=0:mailto:[email protected] | |
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;RSVP=TRU | |
E;CN=Joe Hu;X-NUM-GUESTS=0:mailto:[email protected] | |
CREATED:20150717T132253Z | |
DESCRIPTION:View your event at | |
LAST-MODIFIED:20150717T134925Z | |
LOCATION: | |
SEQUENCE:20 | |
STATUS:CONFIRMED | |
SUMMARY:RFC2446 Test New From Client 2 | |
TRANSP:OPAQUE | |
END:VEVENT | |
END:VCALENDAR | |
--047d7bf0e8e4de0bc9051b121544-- | |
--047d7bf0e8e4de0bd8051b121546--""" | |
print(requests.post( | |
"https://api.mailgun.net/v3/sapikachu.net/messages.mime", | |
auth=("api", "<reducted>"), | |
data={ | |
"to": "[email protected]", | |
}, | |
files={"message": ("test.eml", body)}, | |
).text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment