Send PDF File through Email using pdf-mail module

pdf_mail module is that library of Python which helps you to send pdf documents through your Gmail account.

Installing Library

This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.

pip install pdf-mail

Function of pdf_mail

This module only comes with a single functionality of sending mail from one account to another. The function used to do the same is –

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

Note :

  • It should be noted that the address_of_file must contain forward slash (/) .
  • You have to update the google account settings for sending a email .
    account.google.com -> less secure apps -> Turn on access .

Below is the implementation.

filter_none

edit
close

play_arrow

link
brightness_4
code

# Importing sendpdf function  
# From pdf_mail Library   
from pdf_mail import sendpdf
  
# Taking input of following values
# ex-"abcd@gmail.com" 
sender_email_address = input() 
  
# ex-"xyz@gmail.com" 
receiver_email_address = input() 
  
# ex-" abcd1412" 
sendere_email_password = input()
  
# ex-"Heading of email"
subject_of_email = input()    
   
# ex-" Matter to be sent"
body_of_email = input()
   
# ex-"Name of file" 
filename = input()        
  
# ex-"C:/Users / Vasu Gupta/ "
location_of_file = input() 
  
  
# Create an object of sendpdf function 
k = sendpdf(sender_email_address, 
            receiver_email_address,
            sender_email_password,
            subject_of_email,
            body_of_email,
            filename,
            location_of_file)
  
# sending an email
k.email_send()

chevron_right


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.