A
A
altertable2020-06-16 19:09:17
Heroku
altertable, 2020-06-16 19:09:17

Django 3 deployed a project on heroku and the system for sending emails to gmail broke, everything worked from the local server, how to fix it?

When sending, we get the status 500 server error, help me figure out this error.
Everything went fine from the local server!

form submit handler

subject = name_cinema
        html_message = render_to_string('app_template/mail_template.html', context)
        plain_message = strip_tags(html_message)
        from_email = 'From <[email protected]>'
        to = email

        mail.send_mail(subject, plain_message, from_email, [to], html_message=html_message)


form
<form action="{% url 'app:get_ticket' session.id place.id price_total %}" method="get" >
  {% csrf_token %}
  <div class="input-group">
     <input type="email" name="email_input" class= "input-email" id="formGroupExampleInput" placeholder="E-mail" required>
    <div class="input-group-append">
      <button class="btn btn-success" type="submit">{% trans 'Забронювати' %}</button>
    </div>
  </div>
</form>


setings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'example12345'
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False


logs in heroku
2020-06-16T15:30:06.545465+00:00 app[web.1]: [22, 62, 7, 75, 80, 56, 8, 39, 43, 86, 37, 4, 10]
2020-06-16T15:30:06.545505+00:00 app[web.1]: 22627758056839438637410
2020-06-16T15:30:06.643792+00:00 app[web.1]: 10.9.82.245 - - [16/Jun/2020:18:30:06 +0300] "GET /en/get_ticket/46/16696/74/?csrfmiddlewaretoken=plDZFaLdUMi1v465sP5JuSdDQivCOTv81bnjVzB6K6hZ8yPmhkG4jWR0VvHcnHgx&email_input=reabko15%40gmail.com HTTP/1.1" 500 145 "https://cinemaxpro.herokuapp.com/en/reservation_ticket/3/46/1/16696/1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
2020-06-16T15:30:06.650099+00:00 heroku[router]: at=info method=GET path="/en/get_ticket/46/16696/74/?csrfmiddlewaretoken=plDZFaLdUMi1v465sP5JuSdDQivCOTv81bnjVzB6K6hZ8yPmhkG4jWR0VvHcnHgx&email_input=reabko15%40gmail.com" host=cinemaxpro.herokuapp.com request_id=84f1f3d1-4d9b-4d97-a549-d2198aa8376f fwd="176.120.63.218" dyno=web.1 connect=0ms service=108ms status=500 bytes=402 protocol=https

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2020-06-16
@vityareabko

Use Add-on from this list , they are specially designed for this )
I recommend SendGrid
If you want to eat a cactus, you can look here

Go to Allow less secure apps and choose "Allow" to let less secure apps access your Google account. We don't recommend this option because it may make it easier for someone to gain access to your account.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question