1

I have an automated messaging system that sends emails with the three standard parameters, those being: To, destination and subject. The message is immediately sent after an error has been detected.

The message is being sent over Python, it receives the HTML-body from the monitoring system, it's NOT in the script itself. However, after I used mail-tester it came to light that I was missing the 'to' and 'date' header. However, I can't seem to find a way to add either of these two. I did some research and found out that there you can add mail options but can't find any parameters for this.

I also intend to send a plain-text only copy.

If there isn't an answer to this problem, what code should I try next to try and nail it down, PHP?

#!/usr/bin/env python

list1=[0, 1, 2, 3, 4];

import mimetypes, os, smtplib, sys
from email import encoders
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formatdate


FROM='x@xx.com'
SRVSMTP='mysmtpserver:587'
DESTINATION=sys.argv[1]
SUBJECT=sys.argv[2]
MESSAGE=sys.argv[3]
PASS='xxxxxx'

msg = MIMEMultipart()
msg['From'] = FROM
msg['Subject'] = SUBJECT
msg['To'] = DESTINATION
msg['Date'] = formatdate()

msg.attach(MIMEText(MESSAGE, 'html', 'utf-8'))
raw = msg.as_string()

smtpserver = smtplib.SMTP(SRVSMTP)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo()
smtpserver.login(FROM, PASS)
smtpserver.sendmail(FROM, DESTINATION , raw)
Melanchole
  • 35
  • 10

0 Answers0