Mail is not sending automatically

I wrote below code for sending email when ever student batch is created



      def on_update(self):
   	self.send_mail()

   def send_mail(self):
   	sub = "hello"
   	content = "Please be informed that you have been added to student batch details for student batch are following {batch_name}".format(batch_name=self.student_batch_name)
   	for student in self.students:
   		email = frappe.db.get_value("Student",{"name":student.student},"student_email_id")
   		try:
   		    send(recipients=email,sender="shahidkhan0211@gmail.com",subject=sub,message=content,reference_doctype = self.doctype, reference_name = self.name,
   			send_priority = 0)
   		except frappe.OutgoingEmailError:
   			print frappe.get_traceback()
   			pass
```


when i add student to student batch 

mail is not sending after seven minute 

but when click send mail button one of the mail is sending

can any one help me please<img src="/uploads/default/original/2X/0/0e40341194cf5fffd884cc9ff5e38f80a289e634.png" width="690" height="212">

when i click button on top right corner this happens and mail successfully sends 

<img src="/uploads/default/original/2X/0/05e2c6bf87b9ef2733d351d7298ef94dcb94fbf1.png" width="690" height="387">


please help me with this

@shahid_ecit

Normally emails are queued in Email Queue. If you want to send it directly without queuing.
Just pass one extra flag/parameter to send() method
i.e. delayed=False

@Sangram i have no problem if email is queued but my problem is email is not sending even after 20 mins from queue

Seems like your scheduler is not enable. Run following cmd from frappe-bench to enable it.
bench --site SITENAME enable-scheduler

@Sangram i tried it but not sending

-----Checking scheduler status-----
Workers online: 3
-----None Jobs-----
[shahid@ws23 frappe-think]$ 

this result of bench doctor

Check this one,

@Sangram lock folder is empty

@Sangram

it is related to my problem

Have you followed steps mentioned in shared thread? If you still facing problem, then create GutHub issue here - https://github.com/frappe/frappe/issues

@Sangram yes i tried

and i don’t think this is an issue because when i tried to send email on other instance of erpnext mail was sending

@shahid_ecit,

Can you check for the Error log for any error while sending the mail

@makarand_b there is nothing error log

@makarand_b @Sangram when added extra parameter now=True mail is sending but it t freezes screen for long time

Could you share your code?