Skip to content

Sending a Mail

Ankit Raj Mahapatra edited this page May 2, 2021 · 12 revisions

Function: send_mail(email_sender: str, password: str, subject: str, message: str, email_receiver: str, hostname: str = 'smtp.gmail.com') -> None

This function is used to send emails. The SMTP hostname is the location of the SMTP server for the email service you are using. Here is a list of the SMTP hostnames for some common email services. You don't need to set the PORT.

Example: pywhatkit.send_mail("[email protected]", "password", "Test Mail", "This is a test email", "[email protected]", "smtp.gmail.com")

The password here is the App Password that you can get from your Email Account Settings. There are various guides online on how to setup these. We recommend you to store the message in a variable if it is a long message so that the code remains readable.

Please make sure the Credentials you have entered are correct otherwise you may get an Error!

Clone this wiki locally