I am trying to send an email using python. I am trying to format my email in HTML format. Below is the code:-
sender = '[email protected]'
receivers = ['[email protected]']
message = message = """From: team <[email protected]>
To: To Person <[email protected]>
MIME-Version: 1.0
Content-type: text/html
Subject: Daily Report
<html>
<table>
Report
<% for i in rows: %>
<tr>
<td> <%= rows[0][1] %>
</tr>
<% end %>
</table>
<b>This is HTML message.</b>
<h1>This is headline.</h1>
</html>
"""
smtpObj = smtplib.SMTP('SMTP mailer')
smtpObj.sendmail(sender, receivers, message)
I am fetching rows from Database based on some condition and storing it in "rows" variable. I am trying to loop the HTML table creation based on the number of rows returned.
Whenever i send an email it does not identify the for loop that i have written. It does identify the "This is HTML message" in Bold form and "This is headline" in H1 format
What am i doing wrong?