2013-10-07 17:35:22 +02:00
|
|
|
import mandrill
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
MAIL_CLIENT = None
|
|
|
|
|
2016-06-04 19:52:48 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2013-10-07 17:35:22 +02:00
|
|
|
def get_mandrill_client():
|
2016-06-04 19:52:48 +02:00
|
|
|
# type: () -> Optional[mandrill.Mandrill]
|
2016-08-23 01:25:23 +02:00
|
|
|
if settings.MANDRILL_API_KEY == '' or settings.DEVELOPMENT:
|
2013-10-25 21:19:30 +02:00
|
|
|
return None
|
|
|
|
|
2013-10-07 17:35:22 +02:00
|
|
|
global MAIL_CLIENT
|
2013-10-25 21:19:30 +02:00
|
|
|
if not MAIL_CLIENT:
|
|
|
|
MAIL_CLIENT = mandrill.Mandrill(settings.MANDRILL_API_KEY)
|
|
|
|
|
2013-10-07 17:35:22 +02:00
|
|
|
return MAIL_CLIENT
|
|
|
|
|