This mail never gets delivered. Any ideas why?
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Mon Mar 11 18:34:50 EDT 2013
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
More information about the Python-list
mailing list