From 2c6a0baeda6158e6aeeb6190def866ebae7336b7 Mon Sep 17 00:00:00 2001 From: loomkoom <29258685+loomkoom@users.noreply.github.com> Date: Wed, 25 May 2022 15:11:51 +0200 Subject: [PATCH 1/2] mail --- database.db | Bin 0 -> 16384 bytes flask_app.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 database.db diff --git a/database.db b/database.db new file mode 100644 index 0000000000000000000000000000000000000000..1f61a0b4347abcc731ff0a5a6f01498d2c302cf9 GIT binary patch literal 16384 zcmeI&!EVzq7zc1WF54=xnNF(4jgJ$pTET(Cu5?v4D%x(8RH7$jRJ5T>l`4ahy?byGYrM!FFj;*GXET1S#FWDo;IeSIK z7z+a{wJ-hkeO18Vf6 z!&cXg>4e>gx`!_N?RI_Yx<}#rs7^+wL!DnYCfXP^($}qHl@I?~xLS@m zOWcwAgVASGogV9@rdU|y(#uM!Cc5rMR!{hRhcB+C^q=z?EDZJ)sw^($E;}R}+ho3z zsy~|-WuM7E^0)jYzsqm(i@cDrDxg8JHY;#Spr!7jdb4{~sT6(b3 zqf}TeiIvjhK(O8U)aNSEsf| Date: Wed, 25 May 2022 15:27:39 +0200 Subject: [PATCH 2/2] mail image --- database.db | Bin 16384 -> 16384 bytes flask_app.py | 8 +++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/database.db b/database.db index 1f61a0b4347abcc731ff0a5a6f01498d2c302cf9..a4926464a98a7acf64d4b8ebeaba005d55b4a315 100644 GIT binary patch delta 118 zcmZo@U~Fh$oFL7}GEv5vk!54T5_t|L{x=N#-}v8b7F2k^ufV~?EXr7(S)9Sd!3bm} zCl;k}@-i?mF!5hv;D64438?BAzn(A?8-t{}bbyG^r PjSGvDi&N5yfshFR_F5gl delta 59 zcmZo@U~Fh$oFL7}G*QNxk!fSX5_vX8{%;KY-!=;>+~%J+K~R8$ky(^6Ik6~(la~Pq I1fUY~0Ol_bi2wiq diff --git a/flask_app.py b/flask_app.py index 02c56e9..3a9bbe5 100644 --- a/flask_app.py +++ b/flask_app.py @@ -3,6 +3,7 @@ import string import requests +import os from flask import Flask, jsonify, request, render_template app = Flask(__name__) @@ -56,13 +57,14 @@ def wish_form(card_id): return render_template("send_wish.html", card=card) -def send_mail(email, uid): +def send_mail(email, sender, cardid, uid): x = requests.post("https://api.mailgun.net/v3/sandboxa39931aba4ea43a885c240d815b0a2c2.mailgun.org/messages", auth=("api", "9374b99615d0f43ff1e12995ef3c3317-8d821f0c-6df1ae28"), + files=[('inline[0]', ('card.jpg', open(f'{os.getcwd()}/static/{cardid}.jpg', mode='rb').read()))], data={"from": "laurens@zappsters.pythonanywhere.com", "to": [f"{email}"], "subject": "Greeting card", - "text": "You have been sent an AR greeting card! The unique code for your personnel message is!" + uid}) + "text": f"You have been sent an AR greeting card from {sender}! The unique code for your personnel message i: " + uid}) return x.text @@ -87,7 +89,7 @@ def wish_insert(): uid = generate_uid(db_id) if send_method == "email": - send_mail(send_destination,uid) + send_mail(send_destination,sender,card_id, uid) card = cur.execute('SELECT * FROM card WHERE cardid' + '=' + str(card_id) + ';').fetchone() conn.execute(