[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[msmtp-users] sending email from python?



hi there

i'm having a hard time sending email with msmtp from a python script....

i tried the following :

1)

>>> p = subprocess.Popen(['msmtp','-t'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
>>> p.stdin.writelines(['To: public@...156...', 'Subject: testing', '', ''])
>>> p.stdin.close()
msmtp: recipient address testing not accepted by the server
msmtp: server message: 553-5.1.2 We weren't able to find the recipient
domain. Please check
msmtp: server message: 553-5.1.2 for any spelling errors, and make
sure you didn't enter any
msmtp: server message: 553-5.1.2 spaces, periods, or other punctuation
after the recipient's
msmtp: server message: 553 5.1.2 email address. e20sm5603566fga.1
msmtp: could not send mail (account default from /etc/msmtprc)

2)

>>> p = os.popen('msmtp -t','w')
>>> p.writelines(['To: public@...156...', 'Subject: testing', '', ''])
>>> p.close()
msmtp: recipient address testing not accepted by the server
msmtp: server message: 553-5.1.2 We weren't able to find the recipient
domain. Please check
msmtp: server message: 553-5.1.2 for any spelling errors, and make
sure you didn't enter any
msmtp: server message: 553-5.1.2 spaces, periods, or other punctuation
after the recipient's
msmtp: server message: 553 5.1.2 email address. d13sm9493065fka.3
msmtp: could not send mail (account default from /etc/msmtprc)
16640

3)

>>> p1 = subprocess.Popen(["echo","-e",'"To: public@...156...\nSubject: TESTING\n\n"'], stdout=subprocess.PIPE)
>>> p2 = subprocess.Popen(["msmtp", "-t"], stdin=p1.stdout, stdout=subprocess.PIPE)
>>> output = p2.communicate()[0]
msmtp: no recipients found
msmtp: could not send mail (account default from /etc/msmtprc)

4)

os.system("echo -e 'To: public@...156...\nSubject: testing\n\n' | msmtp -t")
msmtp: no recipients found
msmtp: could not send mail (account default from /etc/msmtprc)
16640

5)

p = subprocess.Popen(['msmtp','public@...156...'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
>>> p.stdin.writelines(['Subject: testing', 'testing', ''])
>>> p.stdin.close()
>>> p.wait()
0

while the fifth try did return without an error, i didn't receive any mail...

this was tested on a stock ubuntu 8.04 server. sending an email
manually on the terminal works as expected.

thanks for any help

claude nobs