0

I am facing a problem when trying to test sending a message from the django app . The problem is that no messages arrive on my email after sending and I don't know what is the reason, please help

this is my settings :

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'myname@gmail.com‏'
EMAIL_HOST_PASSWORD = '****************'
EMAIL_USE_TLS = True
EMAIL_PORT = '587'

this is my views.py:

def contact_us(requset):
    subject = requset.POST.get('subject', '')
    message = requset.POST.get('message', '')
    from_email = requset.POST.get('from_email', '')
    send_mail(subject, message, from_email, 
    ['myname@gmail.com'])
    return render( requset , 'accounts/contact_us.html' )

this is my contact_us.html:

<div class="contact_form">
  <form name="contact_form" action="" method="POST">
    {% csrf_token %}
    <p><input type="text" name="subject" class="name" 
    placeholder="subject" required></p>
    <p><textarea name="message" class="message" 
    placeholder="message" required></textare></p>
    <p><input type="text" name="from_email" class="email" 
    placeholder="email" required></p>           
    <p><input type="submit" value="sent" class="submit_btn"> 
    </p>
  </form>
</div>
  • Please change the port... it should not be string... its integer value... change `EMAIL_PORT = '587'` to `EMAIL_PORT = 587` – Shivendra Pratap Kushwaha Jun 05 '21 at 16:00
  • Unfortunately, the same problem is still stuck with me and that I do not receive any messages on my Gmail knowing that the command prompt tells me that the message has been sent – Tarek elgendy Jun 08 '21 at 16:17

1 Answers1

0

Just remove the single quotes of EMAIL_PORT in your settings.py file. Like

EMAIL_PORT = 587

After that, you need to make some changes in the settings of your Gmail account