This mail never gets delivered. Any ideas why?

  • Thread starter Íßêïò Ãêñ33ê
  • Start date
T

Thomas Rachel

Am 11.03.2013 10:15 schrieb (e-mail address removed):
Thank you Thomas but that simple line as i have it now its capable of
sending mail successfully

Obviously not, otherwise you wouldn't ask, would you?


Thomas
 
T

Thomas Rachel

Am 10.03.2013 19:39 schrieb Íßêïò Ãêñ33ê:
Hey man this worked via Python!
[...]

if( os.system( 'echo "%s" | mail -s "%s" (e-mail address removed)' % (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,
'(e-mail address removed)], 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
 
Í

Íßêïò Ãêñ33ê

Ôç Ôñßôç, 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" (e-mail address removed)' % (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,

'(e-mail address removed)], 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 beworking 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?
 
Í

Íßêïò Ãêñ33ê

Because Python 3 doesnt support MySQLdb moudle yet i decided to use mypysql-0.5.5.tar.gz which i found in google.

problem is that i dont know how to run this file in my webost account so it cant be utilized and so i can pass to Python 3 at last.

i ahve uplaoded the file viua cPnael in webhost but then what?

How doi "embed" this in python so to make use of it?
 
Í

Íßêïò Ãêñ33ê

I'am receiving this now after some tries:

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

/home/nikos/public_html/cgi-bin/metrites.py in ()
139 else:
140 sp = subprocess.Popen(['mail', '-f', FROM, '-s', 'Mail from Guest', '(e-mail address removed)'], stdin=subprocess.PIPE)
=> 141 sp.communicate( MESSAGE )
142 status = sp.wait()
143 if status:
sp = <subprocess.Popen object>, sp.communicate = <bound method Popen.communicate of <subprocess.Popen object>>, MESSAGE = 'kdsjfksdjkfjksdjfs\r\n\t'
/opt/python3/lib/python3.3/subprocess.py in communicate(self=<subprocess.Popen object>, input='kdsjfksdjkfjksdjfs\r\n\t', timeout=None)
901 if input:
902 try:
=> 903 self.stdin.write(input)
904 except IOError as e:
905 if e.errno != errno.EPIPE and e.errno != errno.EINVAL:
self = <subprocess.Popen object>, self.stdin = <_io.BufferedWriter name=5>, self.stdin.write = <built-in method write of _io.BufferedWriter object>, input = 'kdsjfksdjkfjksdjfs\r\n\t'
TypeError: 'str' does not support the buffer interface
args = ("'str' does not support the buffer interface",)
with_traceback = <built-in method with_traceback of TypeError object>
 
C

Cameron Simpson

| I'am receiving this now after some tries:
|
| A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
|
| /home/nikos/public_html/cgi-bin/metrites.py in ()
| 139 else:
| 140 sp = subprocess.Popen(['mail', '-f', FROM, '-s', 'Mail from Guest', '(e-mail address removed)'], stdin=subprocess.PIPE)
| => 141 sp.communicate( MESSAGE )
| 142 status = sp.wait()
| 143 if status:
| sp = <subprocess.Popen object>, sp.communicate = <bound method Popen.communicate of <subprocess.Popen object>>, MESSAGE = 'kdsjfksdjkfjksdjfs\r\n\t'
| /opt/python3/lib/python3.3/subprocess.py in communicate(self=<subprocess.Popen object>, input='kdsjfksdjkfjksdjfs\r\n\t', timeout=None)
| 901 if input:
| 902 try:
| => 903 self.stdin.write(input)

Well, you should probably be writing to sp.stdin, not sys.stdin.

| 904 except IOError as e:
| 905 if e.errno != errno.EPIPE and e.errno != errno.EINVAL:
| self = <subprocess.Popen object>, self.stdin = <_io.BufferedWriter name=5>, self.stdin.write = <built-in method write of _io.BufferedWriter object>, input = 'kdsjfksdjkfjksdjfs\r\n\t'
| TypeError: 'str' does not support the buffer interface
| args = ("'str' does not support the buffer interface",)
| with_traceback = <built-in method with_traceback of TypeError object>

This is symptomatic of sys.stdin (well, whatever you're writing to)
being open in binary mode instead of text mode. And you're passing
a str. Try passing std.encode().

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top