Python SMTP Server protocol - python

I want to build a simple SMTP-Server by using Python which has the ability to authenticate users through default authentication method. No SSL/TLS is needed.
I was able to start a listener on port 25 and connect to different SMTP-Clients like Outlook to log the requests but it seems like it is too complicated to build it by myself.
Is there any library for Python which allows me to create a SMTP-Server and handle the messages by myself? For example, do not send it, but only save a ".eml" file or something.
Thanks for your help!

You should try smtplib
This is the native SMTP library used in Python. Probably is the best to start here and, if you miss something, find a library more robust.
Edit:
For server, you should try SMTPD

Related

How to make requests from back-end to another server on user’s localhost

I’ve got a standard client-server set-up with ReScript (ReasonML) on the front-end and a Python server on the back-end.
The user is running a separate process on localhost:2000 that I’m connecting to from the browser (UI). I can send requests to their server and receive responses.
Now I need to issue those requests from my back-end server, but cannot do so directly. I’m assuming I need some way of doing it through the browser, which can talk to localhost on the user’s computer.
What are some conceptual ways to implement this (ideally with GraphQL)? Do I need to have a subscription or web sockets or something else?
Are there any specific libraries you can recommend for this (perhaps as examples from other programming languages)?
I think the easiest solution with GraphQL would be to use Subscriptions indeed, the most common Rescript GraphQL clients already have such a feature, at least ReasonRelay, Reason Apollo Hooks and Reason-URQL have it.

How to make an SMTP Server in Python to send email?

I was looking around, but I couldn't find a really definite way to setup an SMTP server in Python that can just send messages. I saw inbox.py, but there was a lack of documentation and I couldn't figure out how it works. I don't need to save emails to files, all I need is the ability to send them.
Thanks for any recommendations!

python server-side program to handle email?

What is the easiest way to write a simple Python daemon/server-side program that, in a reasonably secure way, processes incoming messages from an email account? For example, if you have an account 'foo#bar.org' and you have the username/password to the program, you want to be able to have the program read the contents of the email and save them to a database (e.g. with sqlite) in Python. What's the best framework/library for doing this? It sounds like it might be overkill to use Django for something so simple -- can it be done purely with the Python standard libraries?
There are python poplib (http://docs.python.org/2/library/poplib.html) and python imaplib (http://docs.python.org/2/library/imaplib.html). For accessing mailboxes.
Then you have lamson (http://lamsonproject.org/), which is not only excellent for sending and recieving mails. But it can also help you with parsing messages, detecting if they are spam or not - look into lamsons code to see exactly what you can do with it.
Then there are many examples of python daemons, which you can periodically run to pick up mails using poplib/imaplib and then save them somewhere using sqlalchemy or django or whatever.
OR you could skip python daemons and rather create small django project for doing all that. Combined with Celery (https://pypi.python.org/pypi/django-celery), you can create excellent daemonized backend for accessing mailbox via POP or IMAP and saving stuff to your own database.

Python - Sending Data to a .NET Web Service with Authentication

I am working on trying to send XML data to a .NET web service, from an Asterisk Linux box, using Python.
The problems I am running into are:
-- if I use HTTPlib, I can send the XML data; but, the not authenticate first.
-- if I use HTTPlib2, I can authenticate; but, I can't get it to send the data.
In the end, I just need to periodically send data to a client's web service. On my end, I'm not concerned with the response, just sending the data.
Any thoughts on this? Maybe I'm pursuing the wrong path using HTTPlib? Thanks for any assistance at all. I'm not opposed to using a different language; Python just seemed the simplest when this project started.
A very popular module for this is
http://docs.python-requests.org/en/latest/
works great for me for all sorts of requests with and without authentication.

Writing an email sending program in Python

I want to write an email sending script in Python. Most email programs have to connect to existing servers, like Gmail or Hotmail. I want my script to work independantly of those servers and just be able to send email itself (without having to logon anywhere else). The reason for this is because most email servers (like Yahoo) limit what you can do, such as controlling the sender address or sending certain types of files. So I wanted to write my own script to get around that. So what do I do? Where do I begin learning how to do this? Do I have to write my own server? If I do, how is that done?
You need an MTA (a.k.a. mail transfer agent), whether it's local or remote. SMTP servers talk to each other to deliver the mail through — if you don't want to connect to the remote one, you need to run a local one. Look into Postfix or exim — just be careful not to allow random people to connect to it. Go to Server Fault if you need help with configuring them.
This is language-agnostic, BTW.
The email-module of Python should give you a good starting point. Btw this was the first hit when googling Python email.
You'll essentially need to set up your own mail server. I prefer postfix but there are several alternatives, you'll have to google this one.
Once you can send email through your own server, look into smtplib or email-library for sending email with Python

Categories

Resources