Sending parameters to pythons smtplib
Posted on 2009-12-20
I'm using the smtplib library to send emails, but I'd like to use sendmail's -L parameter so that I can assign my own tracking ID in the logs. I can't figure out how to send parameters such as this one with the smtplib library.
The smtp.sendmail() function has 4th and 5th parameters which are optional, but I'm not sure I can use them here. In my code I have:
smtp.sendmail(send_from, send_to, msg.as_string(),"-L12345")
but it gives me an error, "5.5.4 - parameter unrecognized".
If somebody has a solution which doesn't use the smtplib library, that's fine, but I need the ability to send attachments, and I couldn't figure out another easy way of doing this.