Skip to content

Commit

Permalink
Schedule Email
Browse files Browse the repository at this point in the history
  • Loading branch information
phemmylintry committed Jul 16, 2020
1 parent f72ccc6 commit 2c26d6b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion awsmail/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@shared_task()
def send_aws_mail(subject, body, sender, recipient):
send_mail(subject, body, sender, [recipient], fail_silently=False)
send_mail(subject, body, sender, [recipient])
return send_mail()

@shared_task()
Expand Down
Binary file modified newsletter/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified newsletter/__pycache__/views.cpython-36.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions newsletter/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


urlpatterns = [
path('newsletter_all/', views.DisplayAll.as_view(), name='DisplayAll'),
path('create_newsletter/', views.SendNewsletter.as_view(), name='SendEmail'),
path('custom_newsletter/', views.SendCustomMail.as_view(), name='SendCustomMail'),
# path('newsletter_all/', views.DisplayAll.as_view(), name='DisplayAll'),
# path('create_newsletter/', views.SendNewsletter.as_view(), name='SendEmail'),
# path('custom_newsletter/', views.SendCustomMail.as_view(), name='SendCustomMail'),
]
6 changes: 3 additions & 3 deletions newsletter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def post(self, request):
body=request.data['body'],
from_email=settings.EMAIL_HOST_USER,
to_email=request.data['to_email'])
serializer = NewsletterSerializers(data=request.data)
serializer = NewsletterSerializer(data=request.data)
if serializer.is_valid():
validated_data = serializer.validated_data

Expand Down Expand Up @@ -78,10 +78,10 @@ def post(self, request):
subject = serializer.validated_data.get('subject')
from_email = settings.EMAIL_HOST_USER
to_email = serializer.validated_data.get('to_email')
with open(settings.BASE_DIR + '/newsletters/templates/newsletter.txt') as f:
with open(settings.BASE_DIR + '/newsletter/newsletter.txt') as f:
newsletter_mail = f.read()
message = EmailMultiAlternatives(subject, newsletter_mail, from_email, [to_email])
html_template = get_template('newsletter_1.html').render()
html_template = get_template('newsletter/newsletter_1.html').render()
message.attach_alternative(html_template, 'text/html')
message.send()
return Response({'status': 'success',
Expand Down
9 changes: 7 additions & 2 deletions send_certificate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ def post(self, request, *args, **kwargs):
send_aws_mail(subject, message.as_string(), sender, recipient)
return Response({
'status': 'Successful',
'message': 'Confirmation link successfully sent'
'data': {
'message': 'Confirmation link successfully sent'
}

}, status=status.HTTP_200_OK)

else:
send_mail(sender, recipient, subject, content)
return Response({
'status': 'Successful',
'message': 'Confirmation link successfully sent'
'data': {
'message': 'Confirmation link successfully sent'
}
}, status=status.HTTP_200_OK)


Expand Down
4 changes: 2 additions & 2 deletions send_email_microservice/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@


# Celery settings
#CELERY_BROKER_URL = 'amqp://admin:mypass@broker:5672'
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_BROKER_URL = 'amqp://admin:mypass@broker:5672'
# CELERY_BROKER_URL = 'amqp://localhost'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_RESULT_BACKEND = 'db+sqlite:///results.sqlite'
CELERY_TASK_SERIALIZER = 'json'
Expand Down
4 changes: 2 additions & 2 deletions send_email_microservice/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def get_schema(self, request=None, public=False):
path('v1/', include('send_certificate.urls')),
path('v1/', include('scheduler.urls')),
# path('v1/', include('Greetings_mail.urls')),
path('bouncy/', include('django_bouncy.urls')),
path('v1/', include('bounce_notification.urls')),
# path('bouncy/', include('django_bouncy.urls')),
# path('v1/', include('bounce_notification.urls')),
]


Expand Down

0 comments on commit 2c26d6b

Please sign in to comment.