Welcome folks today in this blog post we will be sending pdf file though email
using pdf-mail library. The source code of this tutorial will be given below.
Get Started
In order to get started you need to install pdf-mail
library using the pip command
pip install pdf-mail
Now we want to create app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Importing sendpdf function # From pdf_mail Library from pdf_mail import sendpdf # Create an object of sendpdf function k = sendpdf("##sender##email", "###receiveremail###", "##senderemailpassword##", "##subject of message###", "##bodyofmessage###", "###filename###", "###pathoffile###") # sending an email k.email_send() |
Now in this python script we need to replace the appropriate
values
sender's email address
receiver's email address
sender's password
body of mail
subject of mail
filename
filepath
Before executing this script you need to turn on secure apps access
for your gmail account to send emails on your behalf account.
Now if you execute this python script app.py
you will see following result
Now you can see the email address received in which the pdf file is there.