Commit 5214a1f22c0806735d6a800f6ef1b2e9c143155e

Authored by Jailson Dias
1 parent 293b21cc

resolvendo bugs do tipo Mesmo o email sendo valido ele não envia o email, apenas…

… imprime no terminal o corpo do email.
Showing 2 changed files with 8 additions and 7 deletions   Show diff stats
amadeus/settings.py
... ... @@ -242,8 +242,8 @@ LOGS_URL = 'logs/'
242 242  
243 243  
244 244 # E-mail
245   -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
246   -DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br'
  245 +# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  246 +# DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br'
247 247  
248 248 # Messages
249 249 from django.contrib.messages import constants as messages_constants
... ... @@ -256,9 +256,10 @@ MESSAGE_TAGS = {
256 256 }
257 257  
258 258 #Send email for forgot Password
  259 +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
259 260 EMAIL_USE_TLS = True
260   -DEFAULT_FROM_EMAIL = 'test@gmail.com'
261   -SERVER_EMAIL = 'test@gmail.com'
  261 +DEFAULT_FROM_EMAIL = 'amadeusteste@gmail.com'
  262 +# SERVER_EMAIL = 'amadeusteste@gmail.com'
262 263 EMAIL_HOST = 'smtp.gmail.com'
263 264 EMAIL_PORT = 587
264 265 EMAIL_HOST_USER = 'amadeusteste@gmail.com'
... ...
users/views.py
... ... @@ -412,7 +412,7 @@ class ForgotPassword(generic.FormView):
412 412 subject = ''.join(subject.splitlines())
413 413 email = loader.render_to_string(email_template_name, c)
414 414  
415   - mailsender = MailSender.objects.get(id = 1)
  415 + mailsender = MailSender.objects.latest('id')
416 416  
417 417 if mailsender.hostname == "example.com":
418 418 send_mail(subject, email, settings.DEFAULT_FROM_EMAIL , [user.email], fail_silently=False)
... ... @@ -424,10 +424,10 @@ class ForgotPassword(generic.FormView):
424 424  
425 425 backend = EmailBackend(
426 426 host = mailsender.hostname, port = mailsender.port, username = mailsender.username,
427   - password = mailsender.password, use_tls = tls, fail_silently = False
  427 + password = mailsender.password, use_tls = tls
428 428 )
429 429  
430   - mail_msg = EmailMessage(subject = subject, body = email, from_email = settings.DEFAULT_FROM_EMAIL, to = [user.email], connection = backend)
  430 + mail_msg = EmailMessage(subject = subject, body = email, to = [user.email], connection = backend)
431 431  
432 432 mail_msg.send()
433 433  
... ...