Coders Packet

Send PDF files through emails using Python

By Suryansh Mamgain

A python script to send pdf files through your email using pdf_mail module of python.


    1. pdf_mail module doesn't come with python, therefore you need to install this module by using the command given below:

       pip install pdf-mail


    1. Import sendpdf from the pdf_mail module

    2. Provide the following details asked:

         a) sender email address

         b) sender email password

         c) receiver email address

         d) subject of the mail

         e) body of the mail

         f) filename

         g) location of the file

    3. Create an object of the sendpdf function and pass all the details in this object

    4. Call email-send() method.

          #email_send():  It will send the pdf document from your Gmail account to another Gmail account. 


Before running the code you have to update the Google account settings for sending an email. -> less secure apps -> Turn on access

Download Complete Code


No comments yet