Created
July 4, 2014 05:12
-
-
Save hideaki-t/c8a922f2a5b1f98a8bc5 to your computer and use it in GitHub Desktop.
send to kindle
This file contains 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
import sys | |
from outbox import Outbox, Email, Attachment | |
from pathlib import Path | |
if sys.version_info.major < 3: | |
d = sys.getfilesystemencoding() | |
def u(s): | |
return unicode(s, d) | |
else: | |
def u(s): | |
return s | |
server_cfg = { | |
'username': 'username', | |
'password': 'password', | |
'server': 'smtp_server', | |
'port': '465', | |
'mode': 'SSL', | |
'debug': True | |
} | |
mail_cfg = { | |
'recipients': ['[email protected]'], | |
'subject': 'send to kindle', | |
'body': 'Hello', | |
'fields': {'From': '[email protected]'}, | |
'rfc2231': False | |
} | |
attachments = [ | |
Attachment(u(path.name), fileobj=path.open('rb')) for path in (Path(x) for x in sys.argv[1:]) | |
] | |
Outbox(**server_cfg).send(Email(**mail_cfg), attachments=attachments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment