How to connect mail server with smtplib module in python?

0 votes

Hi Guys,

I am trying to connect mail server using smtplib, but I am not to find the exact functions to do so. Can anyone help me with any python code?

Apr 15 in Python by akhtar
• 24,570 points

1 answer to this question.

0 votes


You can connect mail server using smtplib and ssl module. Use the below given code.

import smtplib,ssl,getpass
smtp_server = ''
port = 465
sender = ''
password = getpass.getpass('Enter your password')
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server,port,context=context) as server:
    print('Successfully connect')

Hope this will help you.

answered Apr 15 by MD
• 55,020 points

Related Questions In Python

0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 57,640 points
0 votes
2 answers

How do I connect to a MySQL Database in Python?

connect mysql database with python import MySQLdb db = ...READ MORE

answered Mar 28, 2019 in Python by rajesh
• 1,230 points
+1 vote
8 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17 in Python by pakainfo
• 200 points
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,520 points
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,349 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

answered Apr 27 in Python by MD
• 55,020 points