This mail never gets delivered. Any ideas why?

Νίκος Γκρ33κ nikos.gr33k at gmail.com
Tue Mar 26 09:49:22 CET 2013


Τη Τρίτη, 12 Μαρτίου 2013 12:34:50 π.μ. UTC+2, ο χρήστης Thomas Rachel έγραψε:
> Am 10.03.2013 19:39 schrieb οΏ½οΏ½οΏ½οΏ½οΏ½ οΏ½οΏ½οΏ½33οΏ½:
> 
> > Hey man  this worked via Python!
> 
> 
> 
> [...]
> 
> 
> 
> > 		if( os.system( 'echo "%s" | mail -s "%s" support at superhost.gr' % (MESSAGE, FROM) ) ):
> 
> 
> 
> [...]
> 
> 
> 
> > Thank you! I beleive this is the simplest way of sending an email!
> 
> 
> 
> Until you get a MESSAGE which has a " sign in it, or a FROM.
> 
> 
> 
> (Sorry, didn't see this message before.)
> 
> 
> 
> In order to prevent trouble with this, it might be better to use 
> 
> subprocess and to do
> 
> 
> 
> sp = subprocess.Popen(['mail', '-f', FROM, '-s', SUBJECT,
> 
>      'support at superhost.gr], stdin=subprocess.PIPE)
> 
> sp.communicate(MESSAGE)
> 
> res = sp.wait()
> 
> if res:
> 
>      ...
> 
> else:
> 
>      ...
> 
> 
> 
> 
> 
> If you do so, you can have FROMs, SUBJECTs and MESSAGEs conaining every 
> 
> character you want, including " and ', an no shell will complain about 
> 
> it or be confused.
> 
> 
> 
> (Note that I changed the arguments for mail a little bit, because -s 
> 
> prevedes the subject and -f the from.)
> 
> 
> 
> 
> 
> Thomas
Hello and sorry for beign so much late to respond.

Yout solution is clearly betetr than the simple mail solution i found to be working but i think subprocess requires that i use  Python3 interpeter which of course my web host supports, but it would fail running my MYSQLdbd module.

So is there still a way to use your solution?



More information about the Python-list mailing list