Comments (5)
@rafaelrds ah, that's a good point. A better approach may be to use source_address
after all then.
from aiosmtplib.
Source address is a string sent to the SMTP server when connecting, identifying the client by IP or hostname (or any string, really). That's not very clear anywhere in the docs, but I don't think it's appropriate to use as local_addr
.
To me the question is if I should add another param to set local_addr. I don't really understand the use case for that, I guess it's required in some network setups? What seems like it should work for that is to establish a socket connection and pass it (via the sock
) param. Does that solve your problem?
from aiosmtplib.
Yes @cole, it is for identifying the hostname and in our case, the sending machine can send e-mails for more than one domain, and has a few possible IPs when binding a socket. Let's say we are hosting from 1.2.3.4
but want to send from 1.2.3.5
if sending from domainA.com and 1.2.3.6
if it is from domainB.com (both are source addresses). I think adding a parameter to set local_addr
might be the finest solution, so it can allow further customization. 🥇
Our current solution was to patch _create_connection
method by creating a subclass of SMTP
.
i.e.
class MySMTP(SMTP):
async def _create_connection(self) -> SMTPResponse:
...
else:
connect_coro = create_connection(
self.loop,
lambda: protocol,
host=self.hostname,
port=self.port,
ssl=tls_context,
ssl_handshake_timeout=ssl_handshake_timeout,
local_addr=(self._source_address, 0),
)
...
As for the use case, some Email Service Providers defers messages when the client-ip
field diverges from the IP presented at EHLO
.
from aiosmtplib.
Hey @cole. I've noticed that the official CPython smtplib
does use the source_address/hostname when creating a socket during connect()
https://github.com/python/cpython/blob/master/Lib/smtplib.py#L339.
from aiosmtplib.
Closed by #167
from aiosmtplib.
Related Issues (20)
- CancelledError thrown when trying to send without authentication HOT 2
- Enabling UTF-8 for Authetication HOT 5
- 4 failing tests HOT 7
- add github issues url to bug reporting docs section HOT 1
- [Debian] Please include CHANGELOG.rst in your pypi releases. HOT 2
- Please support choice of outbound IP address HOT 1
- Suggestion: Support 'TLS optional' usage HOT 3
- Add testing section to docs HOT 2
- Timed out waiting for server ready message HOT 3
- Error trying to use the mail_options or rcpt_options arguments HOT 1
- Do not receive emails using Bcc, Cc headers HOT 2
- Custom DNS resolver HOT 1
- aiosmtplib is not working. [SSL: WRONG_VERSION_NUMBER] wrong version number HOT 1
- packaging issue: deployment of tests HOT 1
- Operation-level timeout HOT 4
- Gives AttributeError when calling with when HOT 2
- Support LMTP HOT 3
- client.connect() call hangs after server timeout HOT 8
- Proxy support HOT 1
- TIP: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiosmtplib.