Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53559 > unrolled thread
| Started by | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| First post | 2013-09-03 10:48 +0300 |
| Last post | 2013-09-05 12:33 -0400 |
| Articles | 20 on this page of 45 — 13 participants |
Back to article view | Back to comp.lang.python
Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-03 10:48 +0300
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-03 02:33 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-03 13:44 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-03 22:14 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-09-04 02:31 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-04 12:16 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-04 17:38 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 09:31 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Steven D'Aprano <steve@pearwood.info> - 2013-09-05 08:58 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 12:34 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 12:36 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Dave Angel <davea@davea.name> - 2013-09-05 10:33 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 13:48 +0300
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-05 04:02 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 14:20 +0300
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-05 05:18 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 15:36 +0300
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-05 06:29 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 16:38 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 17:01 +0300
Re: Cannot form correctly the FORM part of the header when sending mail alex23 <wuwei23@gmail.com> - 2013-09-06 13:38 +1000
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-05 08:00 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-05 18:59 +0300
Re: Cannot form correctly the FORM part of the header when sending mail feedthetroll@gmx.de - 2013-09-05 09:50 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-05 17:50 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-06 00:48 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-06 09:44 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-05 17:28 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-05 11:19 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-09-04 02:57 -0700
Re: Cannot form correctly the FORM part of the header when sending mail Dave Angel <davea@davea.name> - 2013-09-04 11:15 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-04 14:29 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Dave Angel <davea@davea.name> - 2013-09-04 12:21 +0000
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-04 12:22 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Heiko Wundram <modelnine@modelnine.org> - 2013-09-04 14:18 +0200
Re: Cannot form correctly the FORM part of the header when sending mail Ferrous Cranus <nikos@superhost.gr> - 2013-09-04 17:29 +0300
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-04 13:33 -0400
Re: Cannot form correctly the FORM part of the header when sending mail Piet van Oostrum <piet@vanoostrum.org> - 2013-09-04 12:06 -0400
How to exit a cgi file after a download Ferrous Cranus <nikos@superhost.gr> - 2013-09-04 12:49 -0400
How to exit a cgi file after a download. inq1ltd <inq1ltd@inqvista.com> - 2013-09-04 14:44 -0400
Re: How to exit a cgi file after a download. Joel Goldstick <joel.goldstick@gmail.com> - 2013-09-04 15:42 -0400
Re: How to exit a cgi file after a download. alex23 <wuwei23@gmail.com> - 2013-09-05 09:56 +1000
Re: How to exit a cgi file after a download random832@fastmail.us - 2013-09-04 16:23 -0400
Re: How to exit a cgi file after a download Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-09-04 13:51 -0700
Re: How to exit a cgi file after a download inq1ltd <inq1ltd@inqvista.com> - 2013-09-05 12:33 -0400
Page 1 of 3 [1] 2 3 Next page →
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-03 10:48 +0300 |
| Subject | Cannot form correctly the FORM part of the header when sending mail |
| Message-ID | <l0447t$t8a$4@dont-email.me> |
Hello,
i have written the following snipper of code to help me send mail:
=================================================================================================================
# if html form is submitted then send user mail
#================================================================================================================
if( mailform ):
try:
if (FROM is None) or (MESSAGE is None) or ('@' not in FROM) or
('Γράψε μου εδώ' in MESSAGE):
print( "<h2><font color=red>Συμπλήρωσε σωστά το mail σου
και δώσε το σχολιασμό σου!</font></h2>" )
else:
# prepare mail data
TO = "nikos@superhost.gr"
SUBJECT = u"Mail από τον επισκέπτη: ( %s )" % FROM
MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n"
+ MESSAGE + "\r\n"
MESSAGE = MESSAGE % ( FROM, TO, SUBJECT )
MESSAGE = MESSAGE.encode('utf-8')
# open Gmail's SMTP server
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
# next, log in to the server
server.login("nikos.gr33k@gmail.com", "rmrcdherpbsfggcw")
# send the mail
server.sendmail( FROM, [TO], MESSAGE )
print( "<h2><font color=blue>Ευχαριστώ πολύ για το
ενδιαφέρον! Θα επικοινωνήσω μαζί σου άμεσα :-)</font></h2>" )
except Exception as e:
print( repr(e), file=open( '/tmp/err.out', 'a' ) )
sys.exit(0)
=======================================================================
It works as expected, but the the problem is that it display the FROM
part as being send from ,my personal GMail account when it supposed to
be shown the format variable field that was passed by index.html to the
mail.py script.
Si there a workaround for that please?
--
Webhost <http://superhost.gr>
[toc] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-09-03 02:33 -0700 |
| Message-ID | <ced203ff-f577-4824-9902-278a3e208214@googlegroups.com> |
| In reply to | #53559 |
Am Dienstag, 3. September 2013 09:48:13 UTC+2 schrieb Ferrous Cranus:
> Hello,
> i have written the following snipper of code to help me send mail:
> ...
> server.login("nikos.gr33k@gmail.com", "......")
HE DID IT AGAIN! The login works with the posted password!
Nikos, you should change your password IMMEDIATELY!
> ...
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-03 13:44 +0300 |
| Message-ID | <l04ei5$doj$1@dont-email.me> |
| In reply to | #53560 |
Στις 3/9/2013 12:33 μμ, ο/η feedthetroll@gmx.de έγραψε:
> Am Dienstag, 3. September 2013 09:48:13 UTC+2 schrieb Ferrous Cranus:
>> Hello,
>> i have written the following snipper of code to help me send mail:
>> ...
>> server.login("nikos.gr33k@gmail.com", "......")
> HE DID IT AGAIN! The login works with the posted password!
> Nikos, you should change your password IMMEDIATELY!
..
OMG!
I cannot believe i'm being *that* careless, so many times.
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Date | 2013-09-03 22:14 -0400 |
| Message-ID | <m21u55wcxk.fsf@cochabamba.vanoostrum.org> |
| In reply to | #53559 |
Ferrous Cranus <nikos@superhost.gr> writes:
> Hello,
> i have written the following snipper of code to help me send mail:
>
[snip]
> # prepare mail data
> TO = "nikos@superhost.gr"
>
> SUBJECT = u"Mail από τον επισκέπτη: ( %s )" % FROM
>
> MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n"
> + MESSAGE + "\r\n"
> MESSAGE = MESSAGE % ( FROM, TO, SUBJECT )
> MESSAGE = MESSAGE.encode('utf-8')
First a couple of remarks:
1. You should add an empty line between the headers and the message (I
suppose the message does not start with an empty line).
2. It is better to do the % substitution only on the headers, not
including the message, just in case the message contains a % sign.
That makes it:
MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n\r\n" %
( FROM, TO, SUBJECT ) + MESSAGE + "\r\n"
MESSAGE = MESSAGE.encode('utf-8')
3. It is bad coding style in Python to use all-caps variables. Better
use message instead of MESSAGE etc.
[snip]
> It works as expected, but the the problem is that it display the FROM
> part as being send from ,my personal GMail account when it supposed to
> be shown the format variable field that was passed by index.html to the
> mail.py script.
Where does it display that?
Do you happen to read that mail in a Microsoft program?
If yes, then it is the fault of that program. Read the mail in some
other program and you will probably see that the proper From address is
there.
The problem is that Gmail inserts a "Sender" header with your account
(email address) and certain Microsoft programs use that to display as
the From address instead of the real From address. It's against the
rules, but then, Microsoft makes its own rules and who is going to stop
them?
And maybe there are other mail programs that do the same. AFAIK there is
no way to get rid of that Sender line.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos.gr33k@gmail.com> |
|---|---|
| Date | 2013-09-04 02:31 -0700 |
| Message-ID | <47707536-3398-4ce7-9872-da90073d7e93@googlegroups.com> |
| In reply to | #53588 |
Τη Τετάρτη, 4 Σεπτεμβρίου 2013 5:14:31 π.μ. UTC+3, ο χρήστης Piet van Oostrum έγραψε:
> Ferrous Cranus <nikos@superhost.gr> writes:
>
>
>
> > Hello,
>
> > i have written the following snipper of code to help me send mail:
>
> >
>
>
>
> [snip]
>
>
>
> > # prepare mail data
>
> > TO = "nikos@superhost.gr"
>
> >
>
> > SUBJECT = u"Mail από τον επισκέπτη: ( %s )" % FROM
>
> >
>
> > MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n"
>
> > + MESSAGE + "\r\n"
>
> > MESSAGE = MESSAGE % ( FROM, TO, SUBJECT )
>
> > MESSAGE = MESSAGE.encode('utf-8')
>
>
>
> First a couple of remarks:
>
> 1. You should add an empty line between the headers and the message (I
>
> suppose the message does not start with an empty line).
>
> 2. It is better to do the % substitution only on the headers, not
>
> including the message, just in case the message contains a % sign.
>
> That makes it:
>
> MESSAGE = "From: %s\r\n" + "To: %s\r\n" + "Subject: %s\r\n\r\n" %
>
> ( FROM, TO, SUBJECT ) + MESSAGE + "\r\n"
>
> MESSAGE = MESSAGE.encode('utf-8')
>
> 3. It is bad coding style in Python to use all-caps variables. Better
>
> use message instead of MESSAGE etc.
I this hoq you mean?
# =================================================================================================================
# if html form is submitted then send user mail
# =================================================================================================================
if( mailform ):
try:
if (FROM is None) or (MESSAGE is None) or ('@' not in FROM) or ('Γράψε μου εδώ' in MESSAGE):
print( "<h2><font color=red>Συμπλήρωσε σωστά το mail σου και δώσε το σχολιασμό σου!</font></h2>" )
else:
# prepare mail data
TO = "nikos@superhost.gr"
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')
# open Gmail's SMTP server
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
# next, log in to the server
server.login("nikos.gr33k@gmail.com", "password")
# send the mail
server.sendmail( MESSAGE )
print( "<h2><font color=blue>Ευχαριστώ πολύ για το ενδιαφέρον! Θα επικοινωνήσω μαζί σου άμεσα :-)</font></h2>" )
except Exception as e:
print( "sendmail => %s", date, repr( sys.exc_info() ), file=open( '/tmp/err.out', 'a' ) )
sys.exit(0)
========================
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>)
[toc] | [prev] | [next] | [standalone]
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Date | 2013-09-04 12:16 -0400 |
| Message-ID | <m2ppsov9yy.fsf@cochabamba.vanoostrum.org> |
| In reply to | #53612 |
Ferrous Cranus <nikos.gr33k@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.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
[toc] | [prev] | [next] | [standalone]
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Date | 2013-09-04 17:38 -0400 |
| Message-ID | <m2d2oouv1i.fsf@cochabamba.vanoostrum.org> |
| In reply to | #53636 |
Piet van Oostrum <piet@vanoostrum.org> writes:
> Ferrous Cranus <nikos.gr33k@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 <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 09:31 +0300 |
| Message-ID | <l098gd$ig2$1@dont-email.me> |
| In reply to | #53636 |
Στις 4/9/2013 7:16 μμ, ο/η Piet van Oostrum έγραψε:
> Ferrous Cranus <nikos.gr33k@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>
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2013-09-05 08:58 +0000 |
| Message-ID | <522847af$0$2743$c3e8da3$76491128@news.astraweb.com> |
| In reply to | #53676 |
On Thu, 05 Sep 2013 09:31:41 +0300, Ferrous Cranus wrote:
[...]
> 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
And? What is the error message telling you? Don't just ask for help every
single time you get an exception. The error says:
TypeError: not all arguments converted during string formatting
What does that mean? The string formatting operator is % and you can, and
should, experiment on it yourself:
py> "aaaa %s" % 'hello'
'aaaa hello'
Now try to get the error you see:
py> "aaaa%s" % ('hello', "world")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
You have two strings on the right hand side of the % operator, but only
one %s target on the left.
Now how about this?
py> "aa%s" + "bb%s" % ("hello", "world")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
What's the precedence of + and % operators? Which one gets executed
first? Hint:
py> 8 + 2 % 5
10
py> (8 + 2) % 5
0
py> 8 + (2 % 5)
10
Even though these examples are with ints, not strings, the precedence is
the same.
Go back to your code. Read your code. Does it look closer to this:
8 + 2 % 5
or this?
(8 + 2) % 5
Can you solve this problem now?
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 12:34 +0300 |
| Message-ID | <l09j7i$3fj$3@dont-email.me> |
| In reply to | #53683 |
Even though these examples are with ints, not strings, the precedence is
the same.
Go back to your code. Read your code. Does it look closer to this:
8 + 2 % 5
or this?
(8 + 2) % 5
Can you solve this problem now?
Yes Steven, according to your precedence example now i can:
MESSAGE = ( "From: %s\n" + "To: %s\n" + "Subject: %s\n\n%s\n" ) % (
FROM, TO, SUBJECT, MESSAGE )
MESSAGE = MESSAGE.encode('utf-8')
it just need the whole concatenation thing in parenthesis so to be
executed first but now:
# send the mail
server.sendmail( [ MESSAGE ] )
or
# send the mail
server.sendmail( MESSAGE )
both fail.
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 12:36 +0300 |
| Message-ID | <l09jbp$3fj$4@dont-email.me> |
| In reply to | #53685 |
Στις 5/9/2013 12:34 μμ, ο/η Ferrous Cranus έγραψε:
>
> Even though these examples are with ints, not strings, the precedence is
> the same.
>
> Go back to your code. Read your code. Does it look closer to this:
>
> 8 + 2 % 5
>
> or this?
>
> (8 + 2) % 5
>
>
> Can you solve this problem now?
>
> Yes Steven, according to your precedence example now i can:
>
> MESSAGE = ( "From: %s\n" + "To: %s\n" + "Subject: %s\n\n%s\n" ) % (
> FROM, TO, SUBJECT, MESSAGE )
> MESSAGE = MESSAGE.encode('utf-8')
>
>
>
> it just need the whole concatenation thing in parenthesis so to be
> executed first but now:
>
>
> # send the mail
> server.sendmail( [ MESSAGE ] )
>
> or
>
> # send the mail
> server.sendmail( MESSAGE )
>
> both fail.
The error messge says:
nikos@superhost.gr [~]# cat /tmp/err.out
sendmail => 13-09-05 12:20:53 (<class 'TypeError'>,
TypeError("sendmail() missing 2 required positional arguments:
'to_addrs' and 'msg'",), <traceback object at 0x7f3fb4f44488>)
nikos@superhost.gr [~]#
but all of the needed args are within MESSAGE.
Cant it take it from there?
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-09-05 10:33 +0000 |
| Message-ID | <mailman.85.1378377220.5461.python-list@python.org> |
| In reply to | #53686 |
On 5/9/2013 05:36, Ferrous Cranus wrote:
>
>
> nikos@superhost.gr [~]# cat /tmp/err.out
> sendmail => 13-09-05 12:20:53 (<class 'TypeError'>,
> TypeError("sendmail() missing 2 required positional arguments:
> 'to_addrs' and 'msg'",), <traceback object at 0x7f3fb4f44488>)
> nikos@superhost.gr [~]#
>
> but all of the needed args are within MESSAGE.
> Cant it take it from there?
>
Do you know how to find a link like this?
http://docs.python.org/3.3/library/smtplib.html#smtplib.SMTP.sendmail
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 13:48 +0300 |
| Message-ID | <l09nim$nl0$1@dont-email.me> |
| In reply to | #53688 |
Στις 5/9/2013 1:33 μμ, ο/η Dave Angel έγραψε:
> On 5/9/2013 05:36, Ferrous Cranus wrote:
>
>>
>>
>> nikos@superhost.gr [~]# cat /tmp/err.out
>> sendmail => 13-09-05 12:20:53 (<class 'TypeError'>,
>> TypeError("sendmail() missing 2 required positional arguments:
>> 'to_addrs' and 'msg'",), <traceback object at 0x7f3fb4f44488>)
>> nikos@superhost.gr [~]#
>>
>> but all of the needed args are within MESSAGE.
>> Cant it take it from there?
>>
>
> Do you know how to find a link like this?
>
> http://docs.python.org/3.3/library/smtplib.html#smtplib.SMTP.sendmail
>
>
is there way to alter tha FROM field to the one used in the webform by
the visitor?
GMail adds the Sender by default is there some other service that
doesn't and use the FROM field?
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-09-05 04:02 -0700 |
| Message-ID | <3d96733e-d18d-4bed-8fe2-b5e9f2132bad@googlegroups.com> |
| In reply to | #53689 |
Am Donnerstag, 5. September 2013 12:48:54 UTC+2 schrieb Ferrous Cranus:
> is there way to alter tha FROM field to the one used in the webform by
> the visitor?
Yes it ist. You did it in your code.
But gmail alters it AFTER you. So again, you did not care to read / understand the answers you got.
> GMail adds the Sender by default is there some other service that
> doesn't and use the FROM field?
Yes. Already answered:
Am Mittwoch, 4. September 2013 14:18:55 UTC+2 schrieb Heiko Wundram:
> Am 03.09.2013 09:48, schrieb Ferrous Cranus:
>> Is there a workaround for that please?
> Yes, use/setup your own mailserver. Google will not allow you to send
> as ("i.e., From:") an arbitrary address besides the one you've
> authenticated as.
And again, you did not care to read / understand the answers you got.
So again: You are a troll.
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 14:20 +0300 |
| Message-ID | <l09pdn$2he$6@dont-email.me> |
| In reply to | #53690 |
Στις 5/9/2013 2:02 μμ, ο/η feedthetroll@gmx.de έγραψε:
>> Am 03.09.2013 09:48, schrieb Ferrous Cranus:
>>> Is there a workaround for that please?
>> Yes, use/setup your own mailserver. Google will not allow you to send
>> as ("i.e., From:") an arbitrary address besides the one you've
>> authenticated as.
> And again, you did not care to read / understand the answers you got.
>
> So again: You are a troll.
I'm perfectly awra of the answers given to me. I do car to read them and
do care to udnerstand them.
I need information on how to setup my own mail server
i cannot even connect to my 'mail.mydomain.com' mail server like i do
with GMail's.
So:
server = smtplib.SMTP(localhost)
doesn't help, i cannot efen connect to my localhost mail server form
within my script.
An alternative is needed, one that doesnt add up things as Sender but
uses fROM field isntead.
--
Webhost <http://superhost.gr>
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-09-05 05:18 -0700 |
| Message-ID | <1af8193f-c6d0-4bcf-aa72-0f8f6f70c0c9@googlegroups.com> |
| In reply to | #53691 |
Am Donnerstag, 5. September 2013 13:20:23 UTC+2 schrieb Ferrous Cranus:
> Στις 5/9/2013 2:02 μμ, ο/η feedthetroll έγραψε:
>>> Am 03.09.2013 09:48, schrieb Ferrous Cranus:
>>>> Is there a workaround for that please?
>>> Yes, use/setup your own mailserver. Google will not allow you to send
>>> as ("i.e., From:") an arbitrary address besides the one you've
>>> authenticated as.
>> And again, you did not care to read / understand the answers you got.
>> So again: You are a troll.
>
> I'm perfectly awra of the answers given to me. I do car to read them and
> do care to udnerstand them.
>
> I need information on how to setup my own mail server
> i cannot even connect to my 'mail.mydomain.com' mail server like i do
> with GMail's.
And you can solve this promblem by asking "How can I change the FROM field with python?" (which was your last question in this context, after you read and understood the cited answers)? ... Good luck!
Beeing serious:
Which mailserver did you install? postfix, exim, sendmail, ...?
Check that and read its dokumentation how to configure authentication.
Then you can use it.
And if you get stuck: A python list is NOT THE RIGHT PLACE to ask questions about the configuration of mailservers. Find the correct list for your mailserver and ask there!
>
> So:
> server = smtplib.SMTP(localhost)
> doesn't help, i cannot efen connect to my localhost mail server form
> within my script.
See above.
> An alternative is needed, one that doesnt add up things as Sender but
> uses fROM field isntead.
No problem. Configure your own mail server the way you want it to work.
But remembering your attitude to security-things it would be better for us if you did NOT adminstrate a mailserver. We do not need another open relay.
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 15:36 +0300 |
| Message-ID | <l09ts2$oq0$1@dont-email.me> |
| In reply to | #53696 |
Στις 5/9/2013 3:18 μμ, ο/η feedthetroll@gmx.de έγραψε: > Beeing serious: > Which mailserver did you install? postfix, exim, sendmail, ...? > Check that and read its dokumentation how to configure authentication. > Then you can use it. > And if you get stuck: A python list is NOT THE RIGHT PLACE to ask questions about the configuration of mailservers. Find the correct list for your mailserver and ask there! My WHM uses DoveCot as enaled mail server but i have no idea how to setip up to work. i cannot connect to it via my python script. i looked over at my WHM for configuration but i didnt find out how to properly configure it. -- Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-09-05 06:29 -0700 |
| Message-ID | <72eb69f7-83b4-4dc4-8cea-a26c8081effb@googlegroups.com> |
| In reply to | #53697 |
Am Donnerstag, 5. September 2013 14:36:19 UTC+2 schrieb Ferrous Cranus:
> Στις 5/9/2013 3:18 μμ, ο/η feedthetroll έγραψε:
>> Beeing serious:
>> Which mailserver did you install? postfix, exim, sendmail, ...?
>> Check that and read its dokumentation how to configure authentication.
>> Then you can use it.
>
>> And if you get stuck: A python list is NOT THE RIGHT PLACE to ask questions
>> about the configuration of mailservers. Find the correct list for your
>> mailserver and ask there!
>
> My WHM
WHM (http://www.globalacronyms.com/whm):
Meaning of Acronym WHM Language Category
Watt Hour Meter Acronym in English Science, Unit Measure,
Chemistry, Biology, Acronym
Work Hour Management Acronym in English General, Common Abbreviation,
Slang, Acronym
> uses DoveCot as enaled mail server but i have no idea how to
> setip up to work.
> i cannot connect to it via my python script.
OK, I should have been more exact:
To send mails you need a "smtp-server" (MTA - Mail Transfer Agent, Message Transport Agent) like postfix, exim, sendmail, ...
DoveCot is good for "reading" mail (="mailbox management", "pop3(s)", "imap(s)"). You cannot send mails using DoveCot. (You can use a WebMailService to access DoveCot for reading and a MTA for sending mails.)
So you have to find out, which MTA you installed (you have root access, don't you) and configure it.
But this is (like so often) becoming extremely offtopic.
> i looked over at my WHM for configuration but i didnt find out how to
> properly configure it.
http://www.dovecot.org/documentation.html - but DoveCot won't help you here.
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 16:38 +0300 |
| Message-ID | <l0a1gh$djc$4@dont-email.me> |
| In reply to | #53708 |
Στις 5/9/2013 4:29 μμ, ο/η feedthetroll@gmx.de έγραψε:
>> uses DoveCot as enaled mail server but i have no idea how to
>> setip up to work.
>> i cannot connect to it via my python script.
> OK, I should have been more exact:
> To send mails you need a "smtp-server" (MTA - Mail Transfer Agent, Message Transport Agent) like postfix, exim, sendmail, ...
>
> DoveCot is good for "reading" mail (="mailbox management", "pop3(s)", "imap(s)"). You cannot send mails using DoveCot. (You can use a WebMailService to access DoveCot for reading and a MTA for sending mails.)
>
> So you have to find out, which MTA you installed (you have root access, don't you) and configure it.
>
> But this is (like so often) becoming extremely offtopic.
i as root just inatslled
sendmail and mailx. i have edited the ~/.mailrc to use:
nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
account gmail {
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=may)gmail
set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite _it_again
}
And now i'm trying to:
cmd = "echo %s | mailx -A gmail -r %s -s %s %s" % (MESSAGE, FROM,
SUBJECT, TO)
p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
output, errors = p.communicate()
print( errors, output )
Any ideas please why this fails to work?
while i remove the '-A gmail' string in the cmd line then i can send
fast mail but only to mail containing the @superhost.gr trail.
i need to be eble to send to external mails to.
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
| From | Ferrous Cranus <nikos@superhost.gr> |
|---|---|
| Date | 2013-09-05 17:01 +0300 |
| Message-ID | <l0a2rc$l83$1@dont-email.me> |
| In reply to | #53709 |
Στις 5/9/2013 4:38 μμ, ο/η Ferrous Cranus έγραψε:
> Στις 5/9/2013 4:29 μμ, ο/η feedthetroll@gmx.de έγραψε:
>>> uses DoveCot as enaled mail server but i have no idea how to
>>> setip up to work.
>>> i cannot connect to it via my python script.
>> OK, I should have been more exact:
>> To send mails you need a "smtp-server" (MTA - Mail Transfer Agent,
>> Message Transport Agent) like postfix, exim, sendmail, ...
>>
>> DoveCot is good for "reading" mail (="mailbox management", "pop3(s)",
>> "imap(s)"). You cannot send mails using DoveCot. (You can use a
>> WebMailService to access DoveCot for reading and a MTA for sending
>> mails.)
>>
>> So you have to find out, which MTA you installed (you have root
>> access, don't you) and configure it.
>>
>> But this is (like so often) becoming extremely offtopic.
>
>
> i as root just inatslled
>
> sendmail and mailx. i have edited the ~/.mailrc to use:
>
>
> nikos@superhost.gr [~/www/cgi-bin]# cat ~/.mailrc
> account gmail {
> set smtp-use-starttls
> set smtp=smtp://smtp.gmail.com:587
> set smtp-auth=login
> set smtp-auth-user=may)gmail
> set smtp-auth-password=my_gmail_pass_not_stupid_enough_to_wite _it_again
> }
>
>
>
> And now i'm trying to:
>
>
> cmd = "echo %s | mailx -A gmail -r %s -s %s %s" % (MESSAGE, FROM,
> SUBJECT, TO)
> p=subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE )
> output, errors = p.communicate()
> print( errors, output )
>
>
> Any ideas please why this fails to work?
> while i remove the '-A gmail' string in the cmd line then i can send
> fast mail but only to mail containing the @superhost.gr trail.
>
> i need to be eble to send to external mails to.
>
Missing "nss-config-dir" variable.
. . . message not sent.
Missing "nss-config-dir" variable.
. . . message not sent.
Missing "nss-config-dir" variable.
. . . message not sent.
Missing "nss-config-dir" variable.
. . . message not sent.
Missing "nss-config-dir" variable.
. . . message not sent.
Missing "nss-config-dir" variable.
. . . message not sent.
is what iam receivign as error output
--
Webhost <http://superhost.gr>
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web