New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Complete example. #3
Comments
plus onezo - Need a small SMTP server on an intranet and this seems like it'd be suitable (read: less madness inducing) than setting up one of the usual suspects. |
I'd love full documentation of what to, sender and body look like. Is body a set of keys and values, an object, etc.? Where do I grab all the fun header items? |
If we're talking about examples we'd love to see, would this be appropriate for receiving an email with an image attachment, saving the file, and putting an entry in a database? |
And wildcard subdomains so I can integrate comments via email into my issue tracker. |
What I'm saying is: do my work for me please and thank you. Just joshin' but yeah a boilerplate example to jump off of would be pretty rad. |
I have an example where I just forward the message to another SMTP server (I was proxying Jenkins, which has no STARTTLS support, to a mail server that only supports STARTTLS). Is that the sort of boilerplate you'd want? The handler just gets the to (list) and from (string) addresses and the body text, you have a lot of freedom to do whatever you want with that. |
As good a starting point as any. Gist? Also: noice. |
By body are you including headers, different body formats and attachments? Great job on the project!
|
"""
Proxy smtp to a starttls server with authentication, from a local
connection.
"""
from inbox import Inbox
from smtplib import SMTP
inbox = Inbox()
SMTP_HOST = 'mail.example.com'
SMTP_USERNAME = 'username'
SMTP_PASSWORD = 'password'
@inbox.collate
def handle(to, sender, body):
"""
Forward a message via an authenticated SMTP connection with
starttls.
"""
conn = SMTP(SMTP_HOST, 25, 'localhost')
conn.starttls()
conn.ehlo_or_helo_if_needed()
conn.login(SMTP_USERNAME, SMTP_PASSWORD)
conn.sendmail(sender, to, body)
conn.quit()
inbox.serve(address='0.0.0.0', port=4467) |
And an example message body
|
Cheers! A great starting point, thanks for sharing |
How does it call the handle?We know we must call the process_message function, but we can not get it out and call it! |
Any example about receiving emails? |
I would love to start using this. But the problem is I don't know exactly what to once I get a call to my handle method. Could this possibly used to make a very simple email server? Could I find a way to replace say Courier? An example that shows you what to do once you have it set up and running would be awesome.
The text was updated successfully, but these errors were encountered: