Glchriste / Tutoring-Application

A web application that allows students to make appointments with tutors in the CCI tutoring center.
0 stars 1 forks source link

send_email #1

Closed chinmai-padalkar closed 10 years ago

chinmai-padalkar commented 10 years ago

Hi,

I have a doubt with the view.py file. Could you please explain me how the send_email works. The code related to send_email after making an appointment is on line 129 onwards.

recipients = [student_email,tutor_emails[tutor]]

Send Email to Student

    #send_mail('Tutoring Appointment Scheduled', 'Confirming CCI ' + title, student_email, recipients)
    send_mail('Tutoring Appointment Scheduled', 'Confirming CCI ' + title, 'cpadalka@uncc.edu',recipients,fail_silently=False)
    #Send Email to Tutor(s)
    #send_mail('Tutoring Appointment Scheduled', 'Confirming CCI ' + title, tutor_emails[tutor], recipients)

Thanks in advance.

Glchriste commented 10 years ago

Hi Chinmai,

The send_mail function sends an email if given the appropriate input parameters. The function also must be imported from Django's mail module.

The parameters are as follows: send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, html_message=None)

A basic example: from django.core.mail import send_mail send_mail('Subject here', 'Here is the message.', 'from@example.com', ['to@example.com'], fail_silently=False)

Specifically, send_mail('Tutoring Appointment Scheduled', 'Confirming CCI ' + title, 'cpadalka@uncc.edu',recipients,fail_silently=False) sends an email with the subject "Tutoring Appointment Scheduled" with the email body "Confirming CCI Appointment with Tutor at Time." The email is sent from the student's email (given in the appointment form) and sent to all the emails within the recipient list.

recipient_list is a Python list data structure that contains strings of the emails of the tutors.

The documentation on send_mail here is fairly good: https://docs.djangoproject.com/en/dev/topics/email/

At the moment, UNCC's WiFi does not allow a server running locally on a laptop to open up the port required to send the email (the email port used is set in the settings). So, an email won't be sent at school when the function is called even if the code works. I just tested the email from home, this problem should be fixed once the code/website is on a UNCC server.

chinmai-padalkar commented 10 years ago

Ok. I tried to check by making an appointment and the email was not sent. Was just confused and unaware it email is not sent when we use the UNCC's Wifi. Thanks a lot Grace !