Am 10.03.2013 19:39 schrieb Νίκος Γκρ33κ:
Hey man  this worked via Python!

[...]

                if( os.system( 'echo "%s" | mail -s "%s" supp...@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,
    'supp...@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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to