Piet van Oostrum <p...@vanoostrum.org> writes:

> Ferrous Cranus <nikos.gr...@gmail.com> writes:
>
>> I this hoq you mean?
> [...]
>>                      
>>                      SUBJECT = u"Mail από τον επισκέπτη: ( %s )" % FROM
>>                      
>>                      MESSAGE = "\nFrom: %s\r\n" + "To: %s\r\n" + "Subject: 
>> %s\r\n\r\n" % ( FROM, [TO], SUBJECT ) + MESSAGE + "\r\n"
>>                      MESSAGE = MESSAGE.encode('utf-8') 
> [...]
>> but now iam getting this error message:
>>
>> sendmail => %s 13-09-04 12:29:22 (<class 'TypeError'>, TypeError('not all 
>> arguments converted during string formatting',), <traceback object at 
>> 0x7f0e432e1cb0>)
>>
> That is because you changed TO in [TO]. That causes the error.
>
> ** And the \n at the beginning shouldn't be there. **
>
> MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n\r\n" % ( FROM, TO, 
> SUBJECT ) + MESSAGE + "\r\n"
>
> You could even change that to:
>
> MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n\r\n%s\r\n" % 
> (FROM, TO, SUBJECT, MESSAGE)

There was another error in that line:

The string at the left of the % should be in parentheses, or be a single
string:

MESSAGE = ("From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n\r\n%s\r\n") % ( 
FROM, TO, SUBJECT, MESSAGE)

or

MESSAGE = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s\r\n" % ( FROM, TO, 
SUBJECT, MESSAGE)

or even

MESSAGE = "From: %s\r\n" "To: %s\r\n" "Subject: %s\r\n\r\n%s\r\n" % ( FROM, TO, 
SUBJECT, MESSAGE)

Another note:

I did some expriments with Gmail and it seems that it also changes the
From header if the address given is not one that you registerd with your
gmail account. So it is even worse than I thought. (In practice I didn't
notice this because I have all the email addresses I use registered.)
-- 
Piet van Oostrum <p...@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to