Package: pyemail-sender
Python EmailerAboutA utility for sending emails with attachments. Currently only Gmail
is supported.PYPI PackageTable of ContentsUsing the libraryInstalling and using the libraryExamples of usageManually install the libraryPrerequisitesInstall the requirementsRun the Unit TestsContinuous IntegrationUpdate PyPI packageLicenseUsing the libraryFor a detailed usage example seeexample.py.You will need an application-specific password for your Google account.Reference 1,Reference 2Installing and using the libraryFirst, you need to install the library using pip:$pipinstallpyemail_senderThen, import it and initialize it like so:frompyemail_senderimportGmailPyEmailSenderemail_conf={'type':'gmail','config':{'api_key':'your api key','email_address':'youremail@gmail.com'}}pymail=GmailPyEmailSender(config=email_conf)If you want to use a yml file to load the configuration, you can use thePyEmailSenderConfigclass:frompyemail_senderimportPyEmailSenderConfigimportosconfig_path=str(os.path.join('confs','conf.yml'))config=PyEmailSenderConfig(config_src=config_path)email_conf=config.get_pyemail_sender_config()Two example YAML files can be found in
theconfs folder.
For more details on how to use this YAML configuration loader see
thisReadme.Examples of usageSend Simple Emailpymail.send_email(subject='A simple email',to=[email_conf['email_address']],text='Email body text goes here')Send HTML Emailpymail.send_email(subject='A simple HTML email',to=[email_conf['email_address']],html='<h1>Email body with HTML goes here</h1>')Send Email with all the argumentspymail.send_email(subject='Email with all possible arguments',sender=email_conf['email_address'],to=[email_conf['email_address']],cc=[email_conf['email_address']],bcc=[email_conf['email_address']],reply_to=email_conf['email_address'],html='<h1>Test <b>HTML</b> body</h1>',attachments=['my_file.txt'])All of these examples can be found
inexample.py.Manually install the libraryThese instructions will get you a copy of the project up and running on your local machine for
development and testing purposes.PrerequisitesYou need to have a machine withanacondainstalled and
any Bash based shell (e.g. zsh) installed.$ conda -V
conda 4.10.1

$ echo $SHELL
/usr/bin/zshInstall the requirementsAll the installation steps are being handled by
theMakefile.First, modify the python version (min_python) and everything else you need in
thesettings.ini.Then, execute the following commands:$ make create_env
$ conda activate pyemail_sender
$ make distNow you are ready to use and modify the library.Run the Unit TestsIf you want to run the unit tests, execute the following command:$ make testsContinuous IntegrationFor the continuous integration, theCircleCIservice is being used. For more information you can
check thesetup guide.For any modifications, edit
thecircleci config.Update PyPI packageThis is mainly for future reference for the developers of this project. First,
create a file called~/.pypircwith your pypi login details, as follows:[pypi]
username = your_pypi_username
password = your_pypi_passwordThen, modify the python version (min_python), project status (status), release version (version)
and everything else you need in
thesettings.ini.Finally, execute the following commands:$ make create_env
$ conda activate pyemail_sender
$ make releaseFor a dev release, change thetesting_versionand instead ofmake release, runmake release_test.LicenseThis project is licensed under the MIT License - see
theLICENSEfile for details.