How to configure smtp server using python?

0 votes

Hi Guys,

I have one machine learning model. I want to connect this model with smtp server. How can I configure smtp server in my system.

Apr 15 in Python by akhtar
• 10,580 points
24 views

1 answer to this question.

0 votes

Hi@akhtar,

To set smtp server in your system, you have to install smtplib module.

$ pip install smtplib

After that you can use this below code for checking.

import smtplib,getpass
sender='xxxxxxx'
receiver=['xxxxxxx','xxxxxxx']
password=getpass.getpass('Enter your password')
smtpserver=smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(sender,password)
msg='Subject:Demo\nThis is a demo'
smtpserver.sendmail(sender,receiver,msg)
print('Sent')
smtpserver.close()

Hope this will work.

answered Apr 15 by MD
• 23,050 points

Related Questions In Python

+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,760 points
2,328 views
0 votes
2 answers

how to print the current time using python?

print(datetime.datetime.today()) READ MORE

answered Feb 14, 2019 in Python by Shashank
• 1,370 points
92 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 57,530 points
247 views
0 votes
1 answer
+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 947 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

How to transfer multiple lines in a file using python?

Hi@akhtar, I don't know it will help you ...READ MORE

answered Mar 31 in Python by MD
• 23,050 points
68 views
0 votes
1 answer

How to read photo using cv2 module in python?

Hi@akhtar, Yes, you can read your image in ...READ MORE

answered Apr 9 in Python by MD
• 23,050 points
29 views