0

My python script runs on linux server and here is the code that works to send email. But I need to attach a csv/pdf in the email and I couldn't find any straight answer. my email sending method is as shown below

def send_message(recipient, subject, body)
    process = subprocess.Popen(['mail', '-s', subject, recipient],stdin=subprocess.PIPE)
    process.communicate(body)

Note: I tried adding -A flag with filename to be attached, but somehow its not working eg:

process = subprocess.Popen(['mail', '-s', subject, '-A', attachment, recipient],stdin=subprocess.PIPE)

While calling the function I pass the filename directly without path because csv file exists in the same path where script is running, it throws error

trigger_script.go:76: Account gw_ext_ecs_batch_218_seq_1.csv does not exist.

I think its taking it as account instead of attachment

MoshiBin
  • 3,107
  • 2
  • 21
  • 23
viki
  • 165
  • 2
  • 11

1 Answers1

0

using -a instead of -A solved the issue

viki
  • 165
  • 2
  • 11