Commit d2292d8f authored by Georgios Gousios's avatar Georgios Gousios
Browse files

Format and send email

parent 7c3df2b2
......@@ -20,6 +20,9 @@ def _connect():
def send(payload, exchange, key):
Send payload to the specified exchange using the provided routing key
global _conn, _chan
msg = amqp.Message(payload)["delivery_mode"] = 2 # Persistent
......@@ -35,8 +38,6 @@ def send(payload, exchange, key):
except Exception as e:
#self.logger.exception("Caught unexpected exception (msg: %s)", msg)
def __init__():
import smtplib
import json
import time
import socket
from email.mime.text import MIMEText
from email.mime.text import MIMEText
from django.conf import settings
from amqplib import client_0_8 as amqp
import amqp_connection
def send_async(frm, to, subject, body):
def send_async(frm = settings.SYSTEM_EMAIL_ADDR,
to = None, subject = None, body = None):
Queue a message to be sent sometime later
by a worker process.
......@@ -20,25 +23,10 @@ def send_async(frm, to, subject, body):
msg['body'] = body
routekey = ""
amqp_connection.send(json.dumps(msg), settings.EXCHANGE_API, routekey)
msg = amqp.Message(json.dumps(msg))["delivery_mode"] = 2 # Persistent
conn = None
while conn == None:
conn = amqp.Connection(host=settings.RABBIT_HOST,
except socket.error:
chan =
chan.basic_publish(msg,exchange=settings.EXCHANGE_EMAIL, routing_key=routekey)
def send (frm, to, subject, body):
def send (frm = settings.SYSTEM_EMAIL_ADDR,
to = None, subject = None, body = None):
Connect to the email server configured in
and send the email.
......@@ -252,4 +252,6 @@ INVITATION_VALID_DAYS = 30
#SMTP server for the system
#Email account to use for system emails
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment