I want to generate Accounts using usernames and random generated passwords. However. I cannot send Mails with multiple line. A minimal code showing my problem is:
import subprocess
import string
username = Test
randomPassword = abcabc
fromAddr='test@example.com'
toAddr='receive@example.com'
subject='Test Mail'
body='Your Username is ' + username + '\n'+'Your Password is' + randomPassword
cmd='echo '+body+' | mail -s '+subject+' -r '+fromAddr+' '+toAddr
send=subprocess.call(cmd,shell=True)
The error is:
mail: cannot send message: process exited with a non-zero status
/var/log/mail.err shows the follwoing
[SERVERNAME] sSMTP[9002]: RCPT TO:<[SUBJECT]@[SERVERNAME]> (Domain does not exist: [SERVERNME])
A suggestion I found was to use
cmd='echo -e ' +body+ [...]
However this didn't solved the issue.
Any suggestions?