https://github.com/kindlychung/pygmail
Send email through google with python!
https://github.com/kindlychung/pygmail
Last synced: about 2 months ago
JSON representation
Send email through google with python!
- Host: GitHub
- URL: https://github.com/kindlychung/pygmail
- Owner: kindlychung
- License: other
- Created: 2014-06-09T11:38:58.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-09T22:12:06.000Z (over 10 years ago)
- Last Synced: 2024-04-29T11:05:44.235Z (about 1 year ago)
- Language: Python
- Size: 344 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE.txt
Awesome Lists containing this project
README
Description
-----------This is a very simple package that enables you to send mail through
gmail using python. It’s not a big deal, it does not read your emails,
no calendars, no drafts… It does just one thing, sending emails (possibly with attachments).Requirements
------------- Python 3
- pip3 for installationInstall
-------Using ``setup.py``
~~~~~~~~~~~~~~~~~~::
git clone https://github.com/kindlychung/pygmail.git
cd pygmail
python3 setup.py installUsing pip:
~~~~~~~~~~From github:
::
pip3 install --upgrade git+https://github.com/kindlychung/pygmail.git
or from PyPI:
::
pip3 install --upgrade pygmail2
Security
--------It uses smtp, that’s all. You can always check the source code, of
courseUsage
-----You need put your gmail account and password in ~/.pygmailrc, for example:
::
[email protected]
xyz_super_secretFrom the shell:
::
echo "hi there" | gmailsend [email protected] --subj hi --attach /path/to/file
gmailsend [email protected] --subj hi --attach /path/to/file --body_file /path/to/bodyfile
## for help
gmailsend -hFrom python shell you can do things like:
::
from pygmail2.Pygmail import mo
from pygmail2.Addr import ad
# send to one address
mo.sm(to_addr = "[email protected]", subject= "test", text = "hi there")
# send attachments
mo.sm(to_addr = "[email protected]", subject= "test", text = "hi there", attachments = ["/tmp/x.txt", "/tmp/y.png"])
# send to multiple addresses
mo.sm(to_addr = ["[email protected]", "[email protected]"], subject= "test", text = "hi there", attachments = ["/tmp/x.txt", "/tmp/y.png"])
# use html file as mail body
mo.smf(to_addr = ["[email protected]", "[email protected]"], subject= "test", mailfile = "/tmp/x.html", attachments = ["/tmp/x.txt", "/tmp/y.png"])You can store an address book in the csv format in the ~/.pygmail/email.csv file. For example:
::
Xiao Lu,[email protected]
Then you access this email address by:
::
ad.xiao_lu_xl_eepcxx_org
The advantage of this is that you got autocompletion for free.
To save some typing, you can put the following lines in ~/.pygmail/startup.py:
::
from pygmail2.Pygmail import mo
from pygmail2.Addr import adAnd in your ~/.bash_aliases you can say:
::
alias pym='PYTHONSTARTUP=~/.pygmail/startup.py ipython3'
Then every time you want to send an email, you can just start it up by pym.
Change log
----------- single recipient and single attachment now don't require using list
- Enabled attachments
- Email address autocompletion