Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40977 > unrolled thread

This mail never gets delivered. Any ideas why?

Started byΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
First post2013-03-09 13:20 -0800
Last post2013-03-11 17:24 +0100
Articles 9 on this page of 29 — 8 participants

Back to article view | Back to comp.lang.python


Contents

  This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 13:20 -0800
    Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 13:25 -0800
      Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 20:42 -0800
        Re: This mail never gets delivered. Any ideas why? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-10 05:56 +0000
          Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 22:00 -0800
            Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-10 03:19 -0700
            Re: This mail never gets delivered. Any ideas why? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-10 10:37 +0000
              Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-10 11:39 -0700
                Re: This mail never gets delivered. Any ideas why? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-11 23:34 +0100
                  Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 01:49 -0700
                    Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-26 03:26 -0700
                  Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 13:44 -0700
                    Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 13:48 -0700
                      Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 14:43 -0700
                      Re: This mail never gets delivered. Any ideas why? Cameron Simpson <cs@zip.com.au> - 2013-05-27 10:22 +1000
      Re: This mail never gets delivered. Any ideas why? Michael Torrie <torriem@gmail.com> - 2013-03-09 22:07 -0700
        Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 21:10 -0800
          Re: This mail never gets delivered. Any ideas why? Michael Torrie <torriem@gmail.com> - 2013-03-10 10:09 -0600
            Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-10 10:53 -0700
              Re: This mail never gets delivered. Any ideas why? Michael Torrie <torriem@gmail.com> - 2013-03-10 20:20 -0600
            Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-10 10:53 -0700
        Re: This mail never gets delivered. Any ideas why? Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-09 21:10 -0800
      Re: This mail never gets delivered. Any ideas why? Chris Angelico <rosuav@gmail.com> - 2013-03-10 09:15 +1100
    Re: This mail never gets delivered. Any ideas why? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-11 06:25 +0100
      Re: This mail never gets delivered. Any ideas why? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-11 06:47 +0100
        Re: This mail never gets delivered. Any ideas why? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-11 06:59 +0100
    Re: This mail never gets delivered. Any ideas why? nagia.retsina@gmail.com - 2013-03-11 02:15 -0700
      Re: This mail never gets delivered. Any ideas why? Benjamin Schollnick <benjamin@schollnick.net> - 2013-03-11 06:44 -0400
      Re: This mail never gets delivered. Any ideas why? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-11 17:24 +0100

Page 2 of 2 — ← Prev page 1 [2]


#41027

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-03-10 10:53 -0700
Message-ID<mailman.3159.1362938811.2939.python-list@python.org>
In reply to#41020
Τη Κυριακή, 10 Μαρτίου 2013 6:09:53 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:

> You need to post the code snippet that's failing (possibly changing
> private details like smtp server ip address for security reasons), and 
> any exception trace that you are getting!  Other wise, sorry we've done
> all we can.

Michael may i send you an email with my reseller account password so you can try things for yourself because i'am not sure what exactly i must do in the remote jailed unix prompt ?

[toc] | [prev] | [next] | [standalone]


#41003

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-03-09 21:10 -0800
Message-ID<mailman.3148.1362892822.2939.python-list@python.org>
In reply to#41001
Τη Κυριακή, 10 Μαρτίου 2013 7:07:25 π.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:
> On 03/09/2013 02:25 PM, Νίκος Γκρ33κ wrote:
> 
> > mail = form.getvalue('mail')
> 
> > 
> 
> > id what the user types in an html form and click submits. this can be
> 
> > a non valid email of course i just check if there is a '@' in the
> 
> > mail address.
> 
> > 
> 
> > But will the mail, gets delivered even if mail's value is invalid?
> 
> 
> 
> Who knows. You haven't specified how you are sending e-mail.  Likely, if
> 
> an e-mail address is invalid, python still happily hands it off to your
> 
> designated mail server or local MTA (mail transfer agent--could be
> 
> sendmail).  What happens there depends entirely on the policies of the
> 
> mail server or MTA you are using.
> 
> 
> 
> If python is trying to use sendmail, then probably the process would
> 
> just fail and return some sort of error code.  But you will need to
> 
> check on the documentation of whatever e-mail library you are using in
> 
> Python.

I'am using smtplib and i ahve contacted the hostgator administrators and they say that Sendmail is ebaled for my reseller account.

[toc] | [prev] | [next] | [standalone]


#41068

FromChris Angelico <rosuav@gmail.com>
Date2013-03-10 09:15 +1100
Message-ID<mailman.3189.1363014717.2939.python-list@python.org>
In reply to#40979
On Sun, Mar 10, 2013 at 8:25 AM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> mail = form.getvalue('mail')
>
> id what the user types in an html form and click submits. this can be a non valid email of course i just check if there is a '@' in the mail address.
>
> But will the mail, gets delivered even if mail's value is invalid?

I asked the postman to deliver a letter to Dreaded Batter Pudding
Hurler, Bexhill-on-Sea, England 142857. Will that letter get delivered
even if that address is invalid? Is email in any way magical and able
to deliver mail to invalid values, whatever it is you mean by "value"?

ChrisA

[toc] | [prev] | [next] | [standalone]


#41051

FromThomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Date2013-03-11 06:25 +0100
Message-ID<khjpt4$r66$1@r03.glglgl.gl>
In reply to#40977
Am 09.03.2013 22:20 schrieb Νίκος Γκρ33κ:
> 		SENDMAIL = '/usr/sbin/sendmail'
> 			
> 		FROM = mail
> 		TO = ['support@superhost.gr']
> 		SUBJECT = "Επικοινωνία πιθανού πελάτη!"
> 		TEXT = comment
>
> 		message = """\
> 				  From: %s
> 				  To: %s
> 				  Subject: %s
> 					
> 				  %s
> 				  """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
>
> 		p = os.popen("%s -t -i" % SENDMAIL, "w")
> 		p.write(message)
> 		status = p.close()
> 		if status != 256:
> 			print( "<h2><font color=lime>Ευχαριστώ πολύ για το ενδιαφέρον! Θα επικοινωνήσω μαζί σου άμεσα :-)</font></h2>" )
> 		else:
> 			print( "<h2><font color=red>Δυστυχώς δεν μπόρεσε να αποσταλεί το e-mail :-(" )
>
> ===============
>
> Do you see somehtign wrong in the above code?
>

I see some things here:

1. Your subject is not properly encoded.

All characters outside the ASCII area must be encoded in an appropriate 
way if you send an email. It MIGHT be the case that sendmail handles 
this for you, but probably not every version.

But that should not prevent sending the mail at all; probably some 
garbage would result.

2. You failed to tell us what "never gets delivered" means: do you get 
an error message?

3. You failed to give us a SSCCE <http://sscce.org/>: in order to test 
the code, I had to add several variable definitions and imports.

4., an I thik this is the point: you are indenting your message string.
If you put a print(message) somewhere into the code, you'll see that the 
email header lines don't start with the header names, but with spaces. 
That is something which sendmail cannot and won't handle. Likewise, the 
header-body-separator is probably broken as well.

Just write, even if your code is indented in some way:

  		message = """\
From: %s
To: %s
Subject: %s

%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

or maybe, just to be sure,

   		message = "From: %s\nTo: %s\nSubject: %s\n\n%s" % \
                     (FROM, ", ".join(TO), SUBJECT, TEXT)

in order to get a useful result.


And, as you are working on it, don't use os.popen - it is deprecated. 
Better use subprocess:

replace

p = os.popen("%s -t -i" % SENDMAIL, "w")
p.write(message)
status = p.close()

with

import subprocess
sp = subprocess.Popen([SENDMAIL, '-t', '-i'], stdin=subprocess.PIPE)
sp.communicate(message)
status = sp.wait()

giving more flexibility.


HTH,

Thomas

[toc] | [prev] | [next] | [standalone]


#41052

FromThomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Date2013-03-11 06:47 +0100
Message-ID<khjr65$tbr$1@r03.glglgl.gl>
In reply to#41051
Am 11.03.2013 06:25 schrieb Thomas Rachel:

> 1. Your subject is not properly encoded.
>
> All characters outside the ASCII area must be encoded in an appropriate
> way if you send an email. It MIGHT be the case that sendmail handles
> this for you, but probably not every version.

Mine not, at least.

So you should do this:

import email
message = email.message_from_string('')
message.add_header('From', FROM)
message.add_header('To', ", ".join(TO))
# and then

# either
message.add_header('Subject', email.quoprimime.header_encode(SUBJECT))

# or
message.add_header('Subject', email.base64mime.header_encode(SUBJECT))

# Here you should decide upon readability: for Greek text, base64 is
# probably better,  while for languages with Latin characters, quopri
# is better because bost characters remain readable.
#
# The difference is
#
# Subject: 
=?iso-8859-1?q?=CE=95=CF=80=CE=B9=CE=BA=CE=BF=CE=B9=CE=BD=CF=89=CE=BD=CE?=
#  =?iso-8859-1?q?=AF=CE=B1_=CF=80=CE=B9=CE=B8=CE=B1=CE=BD=CE=BF=CF=8D_=CF?=
#  =?iso-8859-1?q?=80=CE=B5=CE=BB=CE=AC=CF=84=CE=B7!?=
#
# vs.
#
# Subject: 
=?iso-8859-1?b?zpXPgM65zrrOv865zr3Pic69zq/OsSDPgM65zrjOsc69zr/PjSDPgM61zrs=?=
#  =?iso-8859-1?b?zqzPhM63IQ==?=
#
#
# If your sender or your recipients have names outside the ASCII area,
# you should quote them as well.


# These are for the text.
message.add_header('MIME-Version', '1.0')
message.add_header('Content-Type', 'text/plain; charset=utf8')
message.add_header('Content-Transfer-Encoding', '8bit')

message.set_payload(TEXT)

# now transform the object into a string:

message = message.as_string()

print message


This message string now can be used for sending.


HTH,

Thomas

[toc] | [prev] | [next] | [standalone]


#41054

FromThomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Date2013-03-11 06:59 +0100
Message-ID<khjrsq$u7o$1@r03.glglgl.gl>
In reply to#41052
Am 11.03.2013 06:47 schrieb Thomas Rachel:

> # either
> message.add_header('Subject', email.quoprimime.header_encode(SUBJECT))
>
> # or
> message.add_header('Subject', email.base64mime.header_encode(SUBJECT))

Sorry! These were completely wrong.

# either
message.add_header('Subject', email.quoprimime.header_encode(SUBJECT,
     charset='utf8'))

# or
message.add_header('Subject', email.base64mime.header_encode(SUBJECT,
     charset='utf8'))

should be correct, however.


But be aware that both seem to potentially break the UTF8 surrogates 
apart, which in turn confuses at least Thunderbird, so it might not be 
the ideal solution.

Maybe you transcode the subject into iso-8859-7 and declare it as such, 
if you only have greek characters.

Let's try:

[...]
# and then
# either
enc = email.base64mime.header_encode
# or
enc = email.quoprimime.header_encode

message.add_header('Subject', enc(
     SUBJECT.decode('utf8').encode('iso-8859-7'),
     charset='iso-8859-7'))

I tried both values for enc(), and both seem to work with the subject 
string you provided.


HTH,


Thomas

[toc] | [prev] | [next] | [standalone]


#41055

Fromnagia.retsina@gmail.com
Date2013-03-11 02:15 -0700
Message-ID<41f45d68-4669-4c51-ae60-d2f22ddf244b@googlegroups.com>
In reply to#40977
Thank you Thomas but that simple line as i have it now its capable of sending mail successfully wven with greek letters two in subject or in message variables.

Now need to dad additional extra code for it to work.

[toc] | [prev] | [next] | [standalone]


#41059

FromBenjamin Schollnick <benjamin@schollnick.net>
Date2013-03-11 06:44 -0400
Message-ID<mailman.3179.1362998655.2939.python-list@python.org>
In reply to#41055

[Multipart message — attachments visible in raw view] — view raw

Nagia,

> Thank you Thomas but that simple line as i have it now its capable of sending mail successfully wven with greek letters two in subject or in message variables.
> 
> Now need to dad additional extra code for it to work.

Your code as it is, isn't working.  They just sent you several suggestions on why it might not be working, and your not even testing to see if it might work better, or assist in tracking down the problem?

Even if these suggestions were completely unfounded, are they more readable then your existing code?  Or more standards compliant?

If you wish to receive help, please at least try to work with the people that are trying to help you.

Otherwise, you'll end up with someone helping you that won't have your best interests in mind.

		- Benjamin

[toc] | [prev] | [next] | [standalone]


#41074

FromThomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Date2013-03-11 17:24 +0100
Message-ID<khl0f9$uac$1@r03.glglgl.gl>
In reply to#41055
Am 11.03.2013 10:15 schrieb nagia.retsina@gmail.com:
> 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

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web