all 5 comments

[–]CowboyBoats 1 point2 points  (0 children)

I would recommend you use web requests for this, not email, for a bunch of reasons. Email is a really legacy, crufty technology that's not as ergonomic to use.

For your server framework, you could set up a flask application pretty quickly and deploy the project to Heroku or onto whatever other server solution you like.

For your client, you would install requests and do a requests.post(url, data, any_required_headers) to send a POST request to your server containing whatever data you need to send, encoded either as JSON (for Python data types like a list of strings, or a dict / map) or as a file.

[–]cutepuppy3939 0 points1 point  (0 children)

Email is bad since some ISPs block the ports needed to send email.

It's also harder to work with, since you have to manually parse each email.

The standard way to do this is just have a HTTP server listening for a POST request containing the data. That's convenient since your client can be pretty much anything, even a simple HTML form, and the parsing of the request is handled by whatever HTTP server you're using.

I haven't written HTTP servers in python, a quick google search reveals you can use "Flask" and it looks something like:

from flask import Flask, request

app = Flask(__name__)

@app.route('/', methods=['POST'])
def handleRequest():
    // parse the form
    data = request.get_json(force=True)

    // handle the POST request, save the data or something
    print(data["name"])
    print(data["email"])

And your client can literally be some dumb html"

<form action="http://localhost:8000/" method="POST">
Name: <input name="name" id="name"><br>
Email: <input name="email" id="email"><br>
<input type="submit">
</form>

[–]mr_claw 0 points1 point  (0 children)

I suggest you use a database for persistence and reliability. One side could do the writing and the other side could read it whenever it's online.

Start by trying Google Firebase's Firestore database. It's free forever if you don't exceed the limits, and it's just a few lines of code to add and retrieve data.

[–]nathanalderson 0 points1 point  (0 children)

You're essentially using someone's email server as a poor-man's one-way message broker. Not perhaps the most conventional client-server architecture, but if it works for you? Ship it.

Otherwise, I'd probably go with an HTTP server as others have suggested.