I am trying to write a python script which sends a html code from my mail id to the target mail id.
It reads the following :
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
me = "prudhvi@domainname.com"
you = "aditya@domainname.com"
msg = MIMEMultipart('multipart')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
html = """\
<html>
<head></head>
<body>
<p>Hi!<br>
How are you?<br>
</p>
</body>
</html>
"""
part = MIMEText(html, 'html')
msg.attach(part)
s = smtplib.SMTP('localhost')
s.sendmail(me, you, msg.as_string())
s.quit()
I have tried running it and came across this error :
Traceback (most recent call last):
File "C:/Users/admin/Desktop/samp.py", line 29, in <module>
s = smtplib.SMTP('localhost')
File "C:\Python27\Lib\smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python27\Lib\smtplib.py", line 316, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\Lib\smtplib.py", line 291, in _get_socket
return socket.create_connection((host, port), timeout)
File "C:\Python27\Lib\socket.py", line 575, in create_connection
raise err
error: [Errno 10061] No connection could be made because the target machine actively refused it
Could I know where I am going wrong?