Cannot form correctly the FORM part of the header when sending mail

Ferrous Cranus nikos at superhost.gr
Thu Sep 5 02:31:41 EDT 2013


Στις 4/9/2013 7:16 μμ, ο/η Piet van Oostrum έγραψε:
> Ferrous Cranus <nikos.gr33k at 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)
>
> which I think is nicer.
>



Now i have it like you said:


UBJECT = u"SuperHost Guest Mail από τον [ %s ]" % FROM
			
MESSAGE = "From: %s\n" + "To: %s\n" + "Subject: %s\n\n%s\n" % (FROM, TO, 
SUBJECT, MESSAGE)
MESSAGE = MESSAGE.encode('utf-8')


but i still get the same error messgae

i use '\n' though and not '\r\n' but this is not an issue.
-- 
Webhost <http://superhost.gr>



More information about the Python-list mailing list