Tryign to send mail via a python script by using the local MTA

F

Ferrous Cranus

try:
# prepare mail data
FROM = random_char(10) + '@' + random_char(10) + '.com'
TO = "(e-mail address removed)"

SUBJECT = random_char( 50 )
MESSAGE = random_char( 500 )

os.system( "echo %s | mailx -v -r %s -s %s %s" % (MESSAGE, FROM, SUBJECT,TO) )

print( "<h2><font color=blue>%sη αποστολή Ï€Ïος %s επετεÏχθη!</font></h2>" % (times, TO) )
except Exception as e:
print( "sendmail => ", date, repr( sys.exc_info() ) )

sys.exit(0)

========================================
========================================

I'am still trying to send successfulyl a mail through my local host by using the local MTA, trying to avoid using GMail's SMTP server but the mail never gets send

this is the error message:

Code:
[email protected] [~/www/cgi-bin]# python mail.py 
LOG: MAIN
cwd=/home/nikos/public_html/cgi-bin 6 args: send-mail -i -v -r [email protected] [email protected]
LOG: MAIN
<= [email protected] U=nikos P=local S=1052 id=5235d7f5..bzP0TUy4ZQEOp7Dh%[email protected] T="QOU0ULMZBF7RGG7B260YERPPXXLTVQ9WKJ93ZXYABQNNA0XB9I"
Content-type: text/html; charset=utf-8

<h2><font color=blue>0η αποστολή Ï€Ïος [email protected] επετεÏχθη!</font></h2>
LOG: MAIN
cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1VLEdZ-0001Xg-6b
delivering 1VLEdZ-0001Xg-6b
[email protected] [~/www/cgi-bin]# LOG: MAIN
SMTP connection outbound 1379260405 1VLEdZ-0001Xg-6b superhost.gr [email protected]
Connecting to gmail-smtp-in.l.google.com [173.194.70.26]:25 ... connected
SMTP<< 220 mx.google.com ESMTP e49si15825947eep.141 - gsmtp
SMTP>> EHLO secure.superhost.gr
SMTP<< 250-mx.google.com at your service, [84.200.17.58]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 CHUNKING
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Ready to start TLS
SMTP>> EHLO secure.superhost.gr
SMTP<< 250-mx.google.com at your service, [84.200.17.58]
250-SIZE 35882577
250-8BITMIME
250-ENHANCEDSTATUSCODES
250 CHUNKING
SMTP>> MAIL FROM:<[email protected]> SIZE=2090
SMTP<< 250 2.1.0 OK e49si15825947eep.141 - gsmtp
SMTP>> RCPT TO:<[email protected]>
SMTP<< 250 2.1.5 OK e49si15825947eep.141 - gsmtp
SMTP>> DATA
SMTP<< 354  Go ahead e49si15825947eep.141 - gsmtp
SMTP>> writing message and terminating "."
SMTP<< 250 2.0.0 OK 1379260407 e49si15825947eep.141 - gsmtp
SMTP>> QUIT
LOG: MAIN
=> [email protected] R=lookuphost T=remote_smtp H=gmail-smtp-in.l.google.com [173.194.70.26] X=TLSv1:RC4-SHA:128
LOG: MAIN
Completed


Since all looks okey why the mail never gets delivered?
 
J

Joost Molenaar

Since the From address is random, it most likely doesn't exist, which
could be reason for Google's smtp server to reject the message or to
deliver it to spam.

Also, the reverse DNS for 84.200.17.58 does not resolve to
secure.superhost.gr, which could also be reason to reject the message.

try:
# prepare mail data
FROM = random_char(10) + '@' + random_char(10) + '.com'
TO = "(e-mail address removed)"

SUBJECT = random_char( 50 )
MESSAGE = random_char( 500 )

os.system( "echo %s | mailx -v -r %s -s %s %s" % (MESSAGE, FROM, SUBJECT, TO) )

print( "<h2><font color=blue>%sη αποστολή Ï€Ïος %s επετεÏχθη!</font></h2>" % (times, TO) )
except Exception as e:
print( "sendmail => ", date, repr( sys.exc_info() ) )

sys.exit(0)

========================================
========================================

I'am still trying to send successfulyl a mail through my local host by using the local MTA, trying to avoid using GMail's SMTP server but the mail never gets send

this is the error message:

Code:
[email protected] [~/www/cgi-bin]# python mail.py
LOG: MAIN
cwd=/home/nikos/public_html/cgi-bin 6 args: send-mail -i -v -r [email protected] [email protected]
LOG: MAIN
<= [email protected] U=nikos P=local S=1052 id=5235d7f5.bzP0TUy4ZQEOp7Dh%[email protected] T="QOU0ULMZBF7RGG7B260YERPPXXLTVQ9WKJ93ZXYABQNNA0XB9I"
Content-type: text/html; charset=utf-8

<h2><font color=blue>0η αποστολή Ï€Ïος [email protected] επετεÏχθη!</font></h2>
LOG: MAIN
cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1VLEdZ-0001Xg-6b
delivering 1VLEdZ-0001Xg-6b
[email protected] [~/www/cgi-bin]# LOG: MAIN
SMTP connection outbound 1379260405 1VLEdZ-0001Xg-6b superhost.gr [email protected]
Connecting to gmail-smtp-in.l.google.com [173.194.70.26]:25 ... connected
SMTP<< 220 mx.google.com ESMTP e49si15825947eep.141 - gsmtp
SMTP>> EHLO secure.superhost.gr
SMTP<< 250-mx.google.com at your service, [84.200.17.58]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250 CHUNKING
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Ready to start TLS
SMTP>> EHLO secure.superhost.gr
SMTP<< 250-mx.google.com at your service, [84.200.17.58]
250-SIZE 35882577
250-8BITMIME
250-ENHANCEDSTATUSCODES
250 CHUNKING
SMTP>> MAIL FROM:<[email protected]> SIZE=2090
SMTP<< 250 2.1.0 OK e49si15825947eep.141 - gsmtp
SMTP>> RCPT TO:<[email protected]>
SMTP<< 250 2.1.5 OK e49si15825947eep.141 - gsmtp
SMTP>> DATA
SMTP<< 354  Go ahead e49si15825947eep.141 - gsmtp
SMTP>> writing message and terminating "."
SMTP<< 250 2.0.0 OK 1379260407 e49si15825947eep.141 - gsmtp
SMTP>> QUIT
LOG: MAIN
=> [email protected] R=lookuphost T=remote_smtp H=gmail-smtp-in.l.google.com [173.194.70.26] X=TLSv1:RC4-SHA:128
LOG: MAIN
Completed


Since all looks okey why the mail never gets delivered?
 
S

SuperHost - Nikos

Στις 15/9/2013 9:59 μμ, ο/η Joost Molenaar έγÏαψε:
Also, the reverse DNS for 84.200.17.58 does not resolve to
secure.superhost.gr, which could also be reason to reject the message.

How can i fix this please?
 
C

Chris Angelico

Since all looks okey why the mail never gets delivered?

This is not a Python question. If it were, I would be asking how
you're getting _anywhere_ with that code, which appears to have
IndentationErrors in it.

You're also using os.system() with interpolated content. What
_exactly_ is random_char() able to return? Is it possible for it to do
the wrong thing there?

ChrisA
 
J

Joel Goldstick

This is not a Python question. If it were, I would be asking how
you're getting _anywhere_ with that code, which appears to have
IndentationErrors in it.


ChrisA

This questions sounds like it should be asked of your hosting company.
They may not allow there servers to be used this way. What have they told
you?
 
S

Steven D'Aprano

Hi Nikos,

I'm now going to put as much care and attention into my answer as you put
into your question.

Have uy tryed imprting os first? u nmeed to do

improt os

first or it wont work.,


When you give evidence of caring about the questions you ask, I'll start
caring about the answers I give you.
 
F

Ferrous Cranus

Στις 16/9/2013 4:52 πμ, ο/η Steven D'Aprano έγÏαψε:
Hi Nikos,

I'm now going to put as much care and attention into my answer as you put
into your question.

Have uy tryed imprting os first? u nmeed to do

improt os

first or it wont work.,


When you give evidence of caring about the questions you ask, I'll start
caring about the answers I give you.
Steven of course i have imported the 'os' module.
I try to send mail from different FROM filed just like as a visitor
guest will use the webform to compete his own email.

but since you ask here is the whole code with the function displayed too.

#=================================================================================================================
# if html form is submitted then send user mail
#=================================================================================================================
def random_char( y, chars=string.ascii_uppercase + string.digits ):
return ''.join( random.choice(chars) for x in range(y) )


for times in range(0, 1):
try:
# prepare mail data
FROM = random_char(10) + '@' + random_char(10) + '.com'
TO = "(e-mail address removed)"

SUBJECT = random_char( 50 )
MESSAGE = random_char( 500 )

os.system( "echo %s | mailx -v -r %s -s %s %s" % (MESSAGE, FROM,
SUBJECT, TO) )

print( "<h2><font color=blue>%sη αποστολή Ï€Ïος %s
επετεÏχθη!</font></h2>" % (times, TO) )
except Exception as e:
print( "sendmail => ", date, repr( sys.exc_info() ) )

sys.exit(0)
==================================================================================================================


Is there a way to avoid the hostname and the ip address from being
revealed when i'am sending an email?

Because the mails finally got delivered to my gmail account after many
hours of delay, and in the headers they are detailes like hostname and
ip address of my server which i dont want to be revealed.

i can alter FROM, TO, subject, message can i also alter the hostname fo
the server the the mail derived from?
 
A

Antoon Pardon

Op 16-09-13 03:52, Steven D'Aprano schreef:
Hi Nikos,

I'm now going to put as much care and attention into my answer as you put
into your question.

Have uy tryed imprting os first? u nmeed to do

improt os

first or it wont work.,


When you give evidence of caring about the questions you ask, I'll start
caring about the answers I give you.

And why do you find it necessary to impart your careless answer on the
list? If you find he doesn't show enough care about the questions he
asks, why don't you just ignore him, instead of showing us all that you
too can contribute in a careless manner?
 
C

Chris Angelico

Op 16-09-13 03:52, Steven D'Aprano schreef:

And why do you find it necessary to impart your careless answer on the
list? If you find he doesn't show enough care about the questions he
asks, why don't you just ignore him, instead of showing us all that you
too can contribute in a careless manner?

bceause its funnyer that way?

Also, how will other people learn that they should put some effort
into their questions? If people are only ever corrected privately,
nobody will learn from anyone else. Orders of magnitude more people
will read this than just the OP, which is why I still respond to jmf
about Unicode even though I know he isn't listening. It's worth it for
the hundreds (thousands? millions? Maybe even more?) of other people
who'll read and learn.

ChrisA
 
C

Chris Angelico

instead of showing us all that you
too can contribute in a careless manner?

Also: It takes effort to contribute usefully in a way that looks
careless :) It's not saving effort, it's making a point.

ChrisA
 
F

Ferrous Cranus

Στις 16/9/2013 10:29 πμ, ο/η Antoon Pardon έγÏαψε:
Op 16-09-13 03:52, Steven D'Aprano schreef:

And why do you find it necessary to impart your careless answer on the
list? If you find he doesn't show enough care about the questions he
asks, why don't you just ignore him, instead of showing us all that you
too can contribute in a careless manner?
My question is not careless.
I have stated exactly the problem and shown relevant code of what i'm
trying to accomplish.

1 have almost 10 responses and not even one of them is being a proper
answer to my initial question.

My question is clear.
 
A

Antoon Pardon

Op 16-09-13 09:44, Chris Angelico schreef:
bceause its funnyer that way?

Funny for who? Personnaly I was rather amused by some of the reactions
that Nikos received and that were ill received by some people here.
So why should your of steve's fun trump my amusment?
Also, how will other people learn that they should put some effort
into their questions? If people are only ever corrected privately,
nobody will learn from anyone else. Orders of magnitude more people
will read this than just the OP,

I didn't complain about his respons being public.
 
C

Chris Angelico

I didn't complain about his respons being public.

http://www.catb.org/esr/faqs/smart-questions.html#not_losing

Sometimes, things are better said than not-said. In fact, that's
*often* true. Maybe it's unpleasant for the person the jab is aimed
at; maybe it feels awkward for you, as an onlooker. But for the good
of python-list, Nikos has to be told that putting minimal effort into
his questions is a bad thing, and if you're going to say that, may as
well say it in a funny way.

Plus, Steven was making a solid point, too. So if you want Nikos to be
ignored by anyone who can't be completely "friendly", what you'll end
up with is materially less content on the list.

ChrisA
 
A

Antoon Pardon

Op 16-09-13 09:46, Chris Angelico schreef:
Also: It takes effort to contribute usefully in a way that looks
careless :) It's not saving effort, it's making a point.

So what? The end result is still a contribution that looks like
it was carelessly written.

Do you think making a point is an end that justifies any kind of
means? If not why do you argue in a way that suggest just that.
If yes, does that mean baiting Nikos is all right if it makes
a point, or responding somewhat obnoxious to him?
 
C

Chris Angelico

Op 16-09-13 09:46, Chris Angelico schreef:

So what? The end result is still a contribution that looks like
it was carelessly written.

It's a contribution that SAYS that it looks carelessly written. I
think most people here are intelligent enough to know that that's
different from actual carelessness.
Do you think making a point is an end that justifies any kind of
means? If not why do you argue in a way that suggest just that.
If yes, does that mean baiting Nikos is all right if it makes
a point, or responding somewhat obnoxious to him?

In a debate, you make points and counterpoints. In most debates, you
also gain (or lose) "points for style". Steven scored plenty of the
latter IMO. You're here making a straw-man and a false dichotomy; I
believe that "making a point" is sufficient justification for what
Steven and I did, but I don't think it justifies "any kind of means".
I would not, for instance, destroy Nikos's server, data, or access to
either, to make a point; and history will confirm this.

ChrisA
 
A

Antoon Pardon

Op 16-09-13 10:19, Chris Angelico schreef:
It's a contribution that SAYS that it looks carelessly written. I
think most people here are intelligent enough to know that that's
different from actual carelessness.

The question is, should they care about that difference. The end
result is a contribution that is just as hard to read.
In a debate, you make points and counterpoints. In most debates, you
also gain (or lose) "points for style". Steven scored plenty of the
latter IMO.

And why should we accept you as the arbiter for this?
You're here making a straw-man and a false dichotomy; I
believe that "making a point" is sufficient justification for what
Steven and I did, but I don't think it justifies "any kind of means".

Then your argument was incomplete, because it just mentioned making
a point as if that in itself was sufficient.
I would not, for instance, destroy Nikos's server, data, or access to
either, to make a point; and history will confirm this.

No it doesn't.
 
C

Chris Angelico

Op 16-09-13 10:19, Chris Angelico schreef:

The question is, should they care about that difference. The end
result is a contribution that is just as hard to read.

Is it, really? I throw the question open: Is it really just as
difficult to read a deliberately-pointed-out sloppiness as an actual
one? And is it as much of a problem to the list?
And why should we accept you as the arbiter for this?

"We" shouldn't. Style points are per-listener. In my eyes he did well.
You may well disagree.
Then your argument was incomplete, because it just mentioned making
a point as if that in itself was sufficient.

Context. Context. Context. Sufficient justification for what it was
used for. You do not seriously believe that that needs to be spelled
out?
No it doesn't.

No? He gave me his root password - check the list archives. I did none
of the above three destructive actions (nor any other destructive
action), even though it would have made my point much stronger to do
so.

ChrisA
 
A

Antoon Pardon

Op 16-09-13 10:48, Chris Angelico schreef:
Is it, really? I throw the question open: Is it really just as
difficult to read a deliberately-pointed-out sloppiness as an actual
one? And is it as much of a problem to the list?

Do you think "improt" is easier to read when written so deliberatly
instead of out of carelessness?
"We" shouldn't. Style points are per-listener. In my eyes he did well.
You may well disagree.

Why do you keep introducing your personal appreciations while at the
same time you admit they don't carry much weight.
Context. Context. Context. Sufficient justification for what it was
used for. You do not seriously believe that that needs to be spelled
out?

Your context adds nothing. The only thing that the context would add,
is that in this specific case you think that the end justifies the means
but it doesn't explain in any way on what grounds you think so. Those
that took Nikos to task earlier for his behaviour probably though their
end justified the means too.

So yes, if you don't want to give the impression that you are simply
ad hoccing what you personnally don't have a problem with, you'd
better spell a few things out.
No? He gave me his root password - check the list archives. I did none
of the above three destructive actions (nor any other destructive
action), even though it would have made my point much stronger to do
so.

You behaved in a way some people clearly thought of a questionable. So
for those people you have established you are prepared to exhibit
questionable behaviour to make your point. So I think there are a
number of people who will think of you as not trustable enough to
withhold the behaviour in question here, when you think it would be
necessary to make your point.
 
F

Ferrous Cranus

Στις 16/9/2013 12:40 μμ, ο/η Antoon Pardon έγÏαψε:
Op 16-09-13 10:48, Chris Angelico schreef:

Do you think "improt" is easier to read when written so deliberatly
instead of out of carelessness?


Why do you keep introducing your personal appreciations while at the
same time you admit they don't carry much weight.


Your context adds nothing. The only thing that the context would add,
is that in this specific case you think that the end justifies the means
but it doesn't explain in any way on what grounds you think so. Those
that took Nikos to task earlier for his behaviour probably though their
end justified the means too.

So yes, if you don't want to give the impression that you are simply
ad hoccing what you personnally don't have a problem with, you'd
better spell a few things out.


You behaved in a way some people clearly thought of a questionable. So
for those people you have established you are prepared to exhibit
questionable behaviour to make your point. So I think there are a
number of people who will think of you as not trustable enough to
withhold the behaviour in question here, when you think it would be
necessary to make your point.
Look,

i want this to stop.
Open your own thread and discuss this if you like.
This is a thread i opened for a specific question and all i see its
irrelevant answers.
 
J

Joost Molenaar

Look,
i want this to stop.
Open your own thread and discuss this if you like.
This is a thread i opened for a specific question and all i see its
irrelevant answers.

Hi Ferrous,

The problem is not in your Python code. You can debug it from the
command line by typing the 'echo ... | mailx' command your Python code
is executing.

Somewhere on your local SMTP or on Google's SMTP, your message is not
being processed the way you want it. There are many things that could
cause this -- SPF, DKIM, reverse DNS not being correct, the From
address being 'faked', or one of about a hunderd other factors. It's
most likely an issue in your local SMTP server's configuration. You'll
have to dive into the logs and do some research on how SMTP works
nowadays to find out what's happening.

But think about this: if I could send mail as (e-mail address removed),
just by typing a shell command, how could we ever trust e-mail to be
from who it really is? What if I send mail as
(e-mail address removed)? What you're doing may look like spam from
Google's point of view, and that's why I think you're not receiving
the message.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top