Sending parameters to pythons smtplib

Posted on 2009-12-20
Medium Priority
Last Modified: 2013-12-17
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.


Question by:midstar
1 Comment
LVL 26

Accepted Solution

jar3817 earned 1880 total points
ID: 26200222
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.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question