Ukimiku
Ukimiku

Reputation: 11

Please advise on constructing the subject line for an email to be sent using ssmtp (on Ubuntu)

Using the ssmtp library and Python (3.10.6), I compose an email message using the following code:

with open(config_filename) as config_file:
                configuration_contents = config_file.read()
                configuration_contents_encoded = configuration_contents.encode()
                version = "0.28"
                subject = f'"TurAlu {version} Configuration file contents"'

                return_status = subprocess.run(["ssmtp", "-s", subject, recipient],\
                                                input=configuration_contents_encoded)

The email is sent, but received with an empty subject line. The "subject" is dropped, it seems.

When I remove the double quotes around the subject, I get the error:

ssmtp: RCPT TO:<TurAlu 0.28 Configuration file [email protected]> (501 <TurAlu 0.28 Configuration [email protected]>: "@" or "." expected after "TurAlu") CompletedProcess(args=['ssmtp', '-s', 'TurAlu 0.28 Configuration file contents', '[email protected]'], returncode=1)

and the email is not sent.

Upvotes: 0

Views: 96

Answers (0)

Related Questions