# Server Error 500, when sending mail

**URL:** <https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783>\
**Category:** Using Django\
**Created:** [September 21, 2021, 1:02pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783 "2021-09-21T13:02:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Invito](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/invito/32/5364_2.png) [@Invito](https://forum.djangoproject.com/u/Invito)\
**Post date:** [September 21, 2021, 1:02pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/1 "2021-09-21T13:02:36Z")

</div>

I’m using Django’s smtp backend to send emails and it works on my local system with DEBUG set to false but fails to work on GoDaddy’s servers… I get the Server Error 500 problem and it points towards:-

```auto
ConnectionRefusedError at /contact/
[Errno 111] Connection refused
Request Method:	POST
Request URL:	https://www.placeholder.com/contact/
Django Version:	3.2.7
Exception Type:	ConnectionRefusedError
Exception Value:	
[Errno 111] Connection refused
Exception Location:	/opt/alt/python37/lib64/python3.7/socket.py, line 716, in create_connection
Python Executable:	/home/jnb3o6uaake2/virtualenv/APT/3.7/bin/python3.7_bin
Python Version:	3.7.11
Python Path:	
['/home/jnb3o6uaake2/APT',
 '/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts',
 '/home/jnb3o6uaake2/virtualenv/APT/3.7/lib64/python37.zip',
 '/home/jnb3o6uaake2/virtualenv/APT/3.7/lib64/python3.7',
 '/home/jnb3o6uaake2/virtualenv/APT/3.7/lib64/python3.7/lib-dynload',
 '/opt/alt/python37/lib64/python3.7',
 '/opt/alt/python37/lib/python3.7',
 '/home/jnb3o6uaake2/virtualenv/APT/3.7/lib/python3.7/site-packages']
Server time:	Tue, 21 Sep 2021 12:59:08 +0000

        send_mail(subject=subject, message=message,from_email="placeholder@placeholder.com", recipient_list=["placeholder@placeholder.com"] …
▼ Local vars
Variable	Value
__class__	
<class 'core.views.ContactPageView'>
body	
{'Email': 'Email: placeholder@gmail.com',
 'Message': '1',
 'Name': 'Name: 12',
 'Phone': 'Phone: placeholder'}
form	
<ContactForm bound=True, valid=True, fields=(name;company;phone;email;message)>
message	
'Name: 12\nEmail: placeholder\nPhone: placeholder\n1'
self	
<core.views.ContactPageView object at 0x2b04035e45d0>
subject	
'Website Inquiry'

```

The sendmail function is highlighted.

```auto
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = 'smtp.rediffmailpro.com'
EMAIL_HOST_USER = 'placeholder@placeholder.com'
EMAIL_HOST_PASSWORD = 'placeholder'
EMAIL_USE_SSL = True
EMAIL_PORT = '465'

```

---

<div class="post-metadata">

**Author:** ![Rigo-Villalta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rigo-villalta/32/5667_2.png) [@Rigo-Villalta](https://forum.djangoproject.com/u/Rigo-Villalta)\
**Post date:** [September 21, 2021, 1:11pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/2 "2021-09-21T13:11:13Z")

</div>

> [@Invito](#):
>
> `https://www.placeholder.com/contact/`

I think you have misunderstanded the instructions of Godaddy. You are pointing to [www.placeholder.com](http://www.placeholder.com), when you have to point to the domain you own is Goddady. You have to change this:

```auto
EMAIL_HOST = 'smtp.rediffmailpro.com'
EMAIL_HOST_USER = 'placeholder@placeholder.com'
EMAIL_HOST_PASSWORD = 'placeholder

```

By the email and password you user in Goddady. By the way, you should use environment variables for this settings.

---

<div class="post-metadata">

**Author:** ![Invito](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/invito/32/5364_2.png) [@Invito](https://forum.djangoproject.com/u/Invito)\
**Post date:** [September 21, 2021, 1:13pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/3 "2021-09-21T13:13:21Z")

</div>

‘placeholder’ is a disguise for my private information eg. name, domain etc.  
I just replaced my information with that

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 21, 2021, 1:29pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/4 "2021-09-21T13:29:14Z")

</div>

Some service providers block certain outbound ports. You need to check with GoDaddy to verify that port 465 is open for you to use. (Internet email spam is a _real_ problem and ISPs take various steps to try and mitigate / limit it.)

---

<div class="post-metadata">

**Author:** ![Rigo-Villalta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rigo-villalta/32/5667_2.png) [@Rigo-Villalta](https://forum.djangoproject.com/u/Rigo-Villalta)\
**Post date:** [September 21, 2021, 1:31pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/5 "2021-09-21T13:31:41Z")

</div>

```auto
ConnectionRefusedError at /contact/
[Errno 111] Connection refused
Request Method:	POST
Request URL:	https://www.placeholder.com/contact/

```

Ok, Even so Django is telling you that it can’t connect with [https://www.placeholder.com/contact/](https://www.placeholder.com/contact/), Have you review the urls config?

---

<div class="post-metadata">

**Author:** ![Invito](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/invito/32/5364_2.png) [@Invito](https://forum.djangoproject.com/u/Invito)\
**Post date:** [September 21, 2021, 2:07pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/6 "2021-09-21T14:07:54Z")

</div>

It works on my local system 😂  
I’m using placeholder as a placeholder for my private information so it doesn’t get leaked…

---

<div class="post-metadata">

**Author:** ![Invito](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/invito/32/5364_2.png) [@Invito](https://forum.djangoproject.com/u/Invito)\
**Post date:** [September 21, 2021, 2:08pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/7 "2021-09-21T14:08:04Z")

</div>

Will look into it ty

---

<div class="post-metadata">

**Author:** ![Rigo-Villalta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rigo-villalta/32/5667_2.png) [@Rigo-Villalta](https://forum.djangoproject.com/u/Rigo-Villalta)\
**Post date:** [September 21, 2021, 7:19pm UTC](https://forum.djangoproject.com/t/server-error-500-when-sending-mail/9783/8 "2021-09-21T19:19:01Z")

</div>

You are connecting you development system to the Godaddy server and It Works? but with the same config in Deployment you can’ t reach the page?  
Do you use a Firewall?
