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

H

Heiko Wundram

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 17.09.2013 13:55, schrieb Joel Goldstick:
At least if you want to add to this nonsense, read each of the
(several?) dozen entries.

Actually, I have read each of the troll cycles (just as I read much of
clp, although I haven't participated much for the last five years),
and found most of them to be rather interesting reads (in their
digression from the original topic).

And: I actually find it rather valuable answering indirectly to things
noticed "along the ride" (or reading what other people answer
indirectly in the same manner) - see my post in this thread where I
pointed out that the original code actually does not sanitize inputs
to a shell command to send mail.

But, again, your impression may differ, and I can respect that.

- --
- --- Heiko.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSOEl/AAoJEDMqpHf921/SAJQIAI48Kzz0js1QqMDkotmMZfdE
XJYwsWlRXtaPhRy1VEGKHiSgCEd71/IVDUOPEv5TuJMy9zfsW1McexrYMW0NW63J
RiAlDmLSITfdPRYqPgmOTA4MqgJ3V2/oAzOpYXwPqs8Qdt92AX5Tr5itDFgua18T
TSdsD4gNudtIMUBkACzMjJKGyxrHvFFhGpUHlFh5swrZhflaGm1TuCWwz3ojTSbG
yoQRPe1ylSjcxkJesaKXR8mIaUMq4mrUaChBe+FwoCJXXs8kkX/EO3KULvKCxQGU
lzsom+b/eTaxB/ttyHwbt7QSsYq1ko2fIeqqDD/jmhTpg5gshOC+JHLs3bUkmMw=
=sTJq
-----END PGP SIGNATURE-----
 
R

Robert Kern

There are members here like Tim Chase who said that they find it interesting to
be able to do what i proposed.

No, he didn't. He was using sarcasm in a vain attempt to inspire you to search
the Python documentation where you could easily find the standard SMTP library.

http://docs.python.org/2/library/smtplib

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
A

Antoon Pardon

Op 17-09-13 14:11, Ferrous Cranus schreef:
Yes you are doing it.
I'm not trolling but trying to solve a specific question and i have
provided code i wrote to do that and explained the reason of why i want
it to work like this.

No you haven't. You have given no explanation at all for why you want
to eliminate those headers.

Since those headers are added to ease finding the source of email abuse
I really am curious to know your motivation for wanting them removed.
I wouldn't waste my time trying code so many days until i make it work.

If you want to think i'm trolling go ahead and do it but please do it in
your own thread not messing up mines.

You are incosiderate by messing up the python list with non python
questions. Yet you demand others to be considerate by not messing up
your thread. Well you can hope I guess.
There are members here like Tim Chase who said that they find it
interesting to be able to do what i proposed.

Tim Chase said no such thing.
It's ok if you dont want to help, but spamming my thread with your
trolling assumptions towards me is tiresome and if you gonna do it open
do it at least in your own thread.

We find it tiresome that you keep coming here with non-python
questions. That doesn't seem to stop you. So why do you think it should
stop others?
 
G

Grant Edwards

Am 17.09.2013 01:41, schrieb Steven D'Aprano:

In addition to that: it's amazing that Nikos thinks TCP will still
work in the presence of spoofed IP addresses. Email without TCP is a
challenge, at the least.

Somehow I doubt Nikos is up to the task of settup up UUCP and a bank
of dial-up modems. Even if he could manage it, there probably isn't
anybody to dial-up...
 
F

Ferrous Cranus

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 17.09.2013 01:41, schrieb Steven D'Aprano:

In addition to that: it's amazing that Nikos thinks TCP will still
work in the presence of spoofed IP addresses. Email without TCP is a
challenge, at the least.

- --
- --- Heiko.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSODMPAAoJEDMqpHf921/SC0YH/3rCWDcX+rzJKonfeJXUYNxz
nbrBPDsoZf6xPh0socOn88TrzgbZewhWf2l3dHAPOKxTAwUWjRjygatTccBmZur9
6B+t410Nq7axz5+0jg4OwBSOQVt3jr0YInK3vWzq4nd0V0cHchvZzfrdSmnEloDU
V3wIPhBM7MEavyuvrxhutIM8DxA/0z6L/cLhwnpHfE6AxVMeGh/dHhGK9eaxJ03C
pfPWgb2fuCRHrOd3+cLUx3ZFF6YkK00PZzICFhkx236K8iaTvBgqIsod2tpyP6+t
H9qlXCfxit1d6nEzTJavx4suBGStcbhDr1C6VlDaPjfVH+w8842h/0QLhTsMXjY=
=K/XL
-----END PGP SIGNATURE-----
So cant this be done in python or not?
or is a mtetr of configuring the MTA? conf file?
 
D

Denis McMahon

So cant this be done in python or not?
or is a mtetr of configuring the MTA? conf file?

Python can not control data that is added to the message after it has
left the python program. If you want to retain maximum possible control
of the mail process from within python, you need to use a python module
that handles the smtp exchange with the destination mta, however even
then you can not control the content of header lines added by that
destination mta, which will invariably include the real[1] ip address of
your system.

[1] The ip address that it is sending ack packets to as part of the smtp
session, so unless you're using a proxy somewhere, this will be your
system's ip address. Can't fake it. If the other system doesn't know your
ip address, it can't send acks, and the tcp session fails.
 
F

Ferrous Cranus

So cant this be done in python or not?
or is a mtetr of configuring the MTA? conf file?

Python can not control data that is added to the message after it has
left the python program. If you want to retain maximum possible control
of the mail process from within python, you need to use a python module
that handles the smtp exchange with the destination mta, however even
then you can not control the content of header lines added by that
destination mta, which will invariably include the real[1] ip address of
your system.

[1] The ip address that it is sending ack packets to as part of the smtp
session, so unless you're using a proxy somewhere, this will be your
system's ip address. Can't fake it. If the other system doesn't know your
ip address, it can't send acks, and the tcp session fails.
Ah, now we are getting somewhere.

So the foreign MTA tests for real time connectivity with the local MTA
and it tries to detect a working host and ip address.

So even if we alter the hostname and the ip address of our localhost
then the smtp procedure will fail correct?
 
C

Chris Angelico

So the foreign MTA tests for real time connectivity with the local MTA and
it tries to detect a working host and ip address.

No, the local MTA connects to the foreign MTA.

ChrisA
 
D

Dennis Lee Bieber

So cant this be done in python or not?
or is a mtetr of configuring the MTA? conf file?

You can't... Those headers get added by the ISP and any other host the
mail passes through.

The more you fake the originator IP/user the more the subsequent
servers will add flags that they can't confirm who sent the mail... And
eventually some filter may drop it as spam.
 
P

Piet van Oostrum

Ferrous Cranus said:
So cant this be done in python or not?
or is a mtetr of configuring the MTA? conf file?

You could write a python program that uses Gmail's web interface. But it is tricky, and if Gmail would change its inyterface you get stuck, and have to do it again, risking that temporarily your email cannot be delivered.

I think you should give up this unholy idea, and just stick with the standard.
 
D

Denis McMahon

So the foreign MTA tests for real time connectivity with the local MTA
and it tries to detect a working host and ip address.

No.

I strongly suggest that you stop trying to write software that transmits
data across tcp/ip networks until you understand how tcp/ip networks
function. This NG is not a networking for dummies course.
 
D

Dennis Lee Bieber

I think you need to read up on some of the most basic fundamentals of tcp/ip networking, i.e., the basis of the global internet. EVERY network packet (and I do mean every) packet in an IP network carries both a source and a destination address in its header. These are fundamentally necessary in order to allow the gateway router at the originating site to direct an outgoing packet to its destination, and allow the receiving host at the destination site to craft reply packets.

Even worse -- IP packets are wrapped by Ethernet packets which use MAC
addresses for direct routing between nodes... Granted, those MAC addresses
may not propagate beyond the next defined gateway IP host, but they do
(theoretically) identify the exact NIC that sent the packet.
 
D

Dave Angel

Even worse -- IP packets are wrapped by Ethernet packets which use MAC
addresses for direct routing between nodes... Granted, those MAC addresses
may not propagate beyond the next defined gateway IP host, but they do
(theoretically) identify the exact NIC that sent the packet.

Noting reliable about the MAC adress. Many systems permit or even
encourage spoofing. And it gets overwritten at each hop, so the other
end cannot easily determine the number a client may have made up.

The first time I added a router to my cable modem, I had to tell it to
use (spoof) the old MAC address so that the cable modem didn't have to
be reprogrammed.
 
J

Jake Angulo

Up Robert Kern's reply!

I was waiting for smtplib <http://docs.python.org/2/library/smtplib> to be
mentioned... finally! Instead people simply answer philosophically. I
dont want to judge whether OP is a troll or not - but i found a lot of
arrogant replies here. I have also worked on an antispam project before,
and see through the intents of the OP, but I do not pretend to be a
moralist. I was hoping we would strictly discuss code or software
architecture here, not morality. Simple question, simple answer pls, in the
interest of the Python list.

To the OP:

You might want to google smtplib, and use that instead of os calling a
system command. Smtplib takes care of all the operating system's quirks for
you, and still uses the os native sendmail program.

On the other hand, the way you are sending email is highly suspect, trying
to spoof a domain, random email address, etc. It is not easy to fool most
modern email servers nowadays - especially gmail's. They verify first that
the sending domain matches the IP of the sender. And if you are trying to
do this - it is neither Python's nor the OS fault.

Happy coding!
 
A

Antoon Pardon

Op 20-09-13 05:56, Jake Angulo schreef:
Up Robert Kern's reply!

I was waiting for smtplib <http://docs.python.org/2/library/smtplib> to
be mentioned... finally! Instead people simply answer philosophically.
I dont want to judge whether OP is a troll or not - but i found a lot
of arrogant replies here.

That is nice. You don't like to judge the OP but you seem to have no
trouble judging others
I have also worked on an antispam project
before, and see through the intents of the OP, but I do not pretend to
be a moralist.

That doesn't sound right after you judged other replies to be arrogant.
I was hoping we would strictly discuss code or software
architecture here, not morality. Simple question, simple answer pls, in
the interest of the Python list.

Well I was hoping, we wouldn't be plagued by trolls or help-vampires
or at least that other wouldn't (spoon) feed them. I guess we can
always hope.
To the OP:

You might want to google smtplib, and use that instead of os calling a
system command. Smtplib takes care of all the operating system's quirks
for you, and still uses the os native sendmail program.

But that won't help in eliminating all the headers Nikos would like
to avoid. Like the receive line that will identify his host.
 
R

Robert Kern

Up Robert Kern's reply!

I was waiting for smtplib <http://docs.python.org/2/library/smtplib> to be
mentioned... finally! Instead people simply answer philosophically. I dont
want to judge whether OP is a troll or not - but i found a lot of arrogant
replies here. I have also worked on an antispam project before, and see through
the intents of the OP, but I do not pretend to be a moralist. I was hoping we
would strictly discuss code or software architecture here, not morality. Simple
question, simple answer pls, in the interest of the Python list.

Please don't valorize my message. I did neither Nikos nor the group any favors.
I can only plead dizziness from the whooshing of Tim's sarcasm flying over
Nikos' head.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
F

feedthetroll

Hi Jake!

Am Freitag, 20. September 2013 05:56:57 UTC+2 schrieb Jake Angulo:
...
I was waiting for smtplib to be mentioned... finally!  Instead people simply
answer philosophically.  I dont want to judge whether OP is a troll or not -
As you do not seem to know the histrory of this topic I will try to summarize (you can find the plethora of posts in the archive):
* Nikos tried to send mails using smtplib via gmail
* gmail did not allow him to use arbitrary FROM adresses (whatever FROM-header he used, gmail changed it to the e-mail of his account). evil, evil gmail ;-)
* He got many, many hints not to send via gmail but use his own MTA
* Nikos configured sendmail to relay mail VIA GMAIL (unfortunately that didnot change anything)
* while using arbitrary things to find the reason (when you browse the archive you will learn, that nikos does not read postings or docs but uses somesort of artistic or random or just chaotic "trial and error" to solve his problems)
* ... he found some other headers he wants to falsify
* the only reference to python is, that he wants to use his python-cgi-scripts to change the mailheaders AFTER the mail left his relaying MTA and evenafter the mail arrives in the inbox of the recipient (received-by-headers,IP-Adresses, ...). The hints to read some docs about TCP/IP, SMTP, ... he ignores as he has to do see http://www.politicsforum.org/images/flame_warriors/flame_62.php (the original by mreed is not reachable today)

hth
 
Î

Îίκος

You can't... Those headers get added by the ISP and any other host the
mail passes through.

The more you fake the originator IP/user the more the subsequent
servers will add flags that they can't confirm who sent the mail... And
eventually some filter may drop it as spam.
Î¥es Denis every foreign MTA adds headers as mail passes over it ( as
proved to be done at least from the gmail's smtp)

But if we set up our local MTA to modify the headers, hostname, ip
address, user) to our own likign then the local MTA will connect to the
foreign MTA and passes it out modifed data , not the real one.

Ιsn't this possible? that is to fake our hostname and ip address?
 

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,771
Messages
2,569,587
Members
45,099
Latest member
AmbrosePri
Top