• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

Sending parameters to pythons smtplib

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.

THANKS!

0
midstar
Asked:
midstar
1 Solution
 
jar3817Commented:
I'm not sure you can do that with smtplib. I'm not even sure that library uses sendmail, I think it just handles the SMTP communication itself, the function having the same name may just be a coincidence.

The 4th and 5th args are for in the middle of the SMTP conversation (at the MAIL FROM: and RCPT TO: stage), well after sendmail would have to be invoked with your -L param.  The error you're getting, "5.5.4 - parameter unrecognized" is the remote system saying it doesn't understand the "-L12345" because you're trying to pass it to a local process when smtplib is passing it to the remote server as part of the conversation.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now