How to send a mail from python.
I used the following 2 sets to send the weblogic server healths report but installed Python 2.7.13 says there is no such mime or message modules. Could please help if there is any other way we can do it? thanks in advance.
set1:
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
#from email.mime.text import MIMEText
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
f = open("demofile3.txt", "r")
# Create a text/plain message
msg = MIMEText(f.read())
# me == the sender's email address
# you == the recipient's email address
#msg['Subject'] = 'The contents of %s' % textfile
msg['Subject'] = 'Testing'
msg['From'] = 'test@abc.com'
msg['To'] = "abc.test.com"
# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()
set2:
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
from email.message import EmailMessage
# Open the plain text file whose name is in textfile for reading.
fp = open("demofile3.txt", "r")
# Create a text/plain message
msg = EmailMessage()
msg.set_content(fp.read())
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'Testing'
msg['From'] = 'test@test.com'
msg['To'] = "abc@test.com"
# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()