I'm running the mailx command from inside a Python program. The program is running on a server in AWS, and I'm using their Simple Email Service to send emails.
Up until now, I've been hardcoding the SES username and password for the SMTP server directly into the Python script. I'm now switching to grabbing the username and password with an API call to AWS to increase security.
How can I rework the Python program to call the mailx command using the username and password stored in the variables SESUsername and SESPassword? The mailx command uses the smtp-auth-user and smtp-auth-password arguments.
Here are the two Python lines:
command = "mailx -v -s \"Subject\" -S ssl-verify=ignore -S smtp-auth=login -S smtp=smtps://email-smtp.us-west-2.amazonaws.com:465 -S from=\"A Person<email@domain.com>\" -S replyto=\"Another Person<email2@domain2.com>\" -S smtp-auth-user=XXXXX -S smtp-auth-password=XXXXX -S nss-config-dir=\"/etc/pki/nssdb/\" person3@domain3.com"
subprocess.Popen(command,shell=True)