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

William Ray Wing wrw at mac.com
Tue Sep 17 18:34:50 EDT 2013


On Sep 17, 2013, at 5:42 PM, Ferrous Cranus <nikos.gr33k at gmail.com> wrote:

> On 17/9/2013 7:30 μμ, Denis McMahon wrote:
>> On Tue, 17 Sep 2013 18:17:43 +0300, Ferrous Cranus wrote:
>> 
>>> 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?
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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.

-Bill


More information about the Python-list mailing list