*You can check out celery and how to integrate it with django. Once done, 
task scheduling is easy,first add your gmail configuration in settings.py 
as follows:*

*EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend' *
*EMAIL_USE_TLS = True *
*EMAIL_HOST = 'smtp.gmail.com' *
*EMAIL_HOST_USER = 'your_email' *
*EMAIL_HOST_PASSWORD = 'your password' *
*DEFAULT_FROM_EMAIL = EMAIL_HOST_USER EMAIL_PORT = 465*

Then in your tasks.py you can add the function for scheduling emails as 
follows:

*from django.template.loader import render_to_string *
*from django.core.mail import EmailMessage*

@periodic_task
( run_every=(crontab(hour=3, minute=34)), #runs exactly at 3:34am every day 
name="Dispatch_scheduled_mail",
 reject_on_worker_lost=True, ignore_result=True) 
def schedule_mail(): 
 message = render_to_string('app/schedule_mail.html') 
 mail_subject = 'Scheduled Email' to_email = getmail email = 
EmailMessage(mail_subject, message, to=[to_email]) 
 email.send()

*Then finally your email template 'schedule_mail.html*
{% autoescape off %} 
Hello , 
 This is a test email if you are seeing this,
 your email got delivered! 
 Regards, Coding Team.
 {% endautoescape %}
On Thursday, July 1, 2021 at 1:54:31 PM UTC+1 divyamu...@gmail.com wrote:

> HI,
>
> I wanted to schedule a email every jan and aug 6 monthly basis without 
> celery using settings.py. Can anyone help?
>
> once in every 6months mail should be triggered
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a87a8623-d123-404d-91b8-d30a01d91dc0n%40googlegroups.com.

Reply via email to