Q:

Why can my EC2 send email though Gmail butnot from a custom domain?

I'm having an issue with my django mailing, apparently i can send email with an gmail account with no problem, but i can't send any email from my custom domain email. 
There is a curios thing, locally my SMTP SSL email works, but loaded on the EC2 instance it doesn't send anything.
I have tried by changing from SMTPSSL to only SMTP but still not working, also I have tried on a heroku instance but again, the heroku instance doesn't even send from gmail as the EC2 instance.
ACCOUNT_EMAIL = os.environ['ACCOUNT_EMAIL']
ACCOUNT_PASSWORD = os.environ['ACCOUNT_PASSWORD']
# EMAIL_PROVIDER = 'smtp.gmail.com' //gmail configurations
# EMAIL_SERVER_PORT = 587
EMAIL_PROVIDER = 'krishna.hosting-mexico.net'
EMAIL_SERVER_PORT = 465
SECURITY_EMAIL_SENDER = ACCOUNT_EMAIL

def send_driver_welcome_email(user_email):
    from_email_address = EMAIL
    from_email_address_password = PASSWORD
    htmly     = get_template('driver_welcome_email.html')

    message = MIMEMultipart('alternative')
    message['Subject'] = 'Bienvenido a TAXI 2.0'
    message['From'] = from_email_address
    message['To'] = user_email

    html_content = htmly.render(None)

    part1 = MIMEText(html_content, 'html')

    message.attach(part1)

    server = smtplib.SMTP(EMAIL_PROVIDER, EMAIL_SERVER_PORT)
    #server = smtplib.SMTP_SSL(EMAIL_PROVIDER, EMAIL_SERVER_PORT) //This works locally
    server.ehlo()
    server.starttls()
    server.login(from_email_address, from_email_address_password)
    server.sendmail(from_email_address, user_email, message.as_string())
    server.quit()

On my console i get the error: (today test)
...
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "/usr/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/mauricio/Documents/vast-reef-49088/touchtaxiapp/views.py", line 104, in manager_add_driver
    send_driver_welcome_email(user_form.cleaned_data['username'].lower())
  File "/home/mauricio/Documents/vast-reef-49088/touchtaxiapp/apis.py", line 115, in send_driver_welcome_email
    server = smtplib.SMTP(EMAIL_PROVIDER, EMAIL_SERVER_PORT)
  File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.7/smtplib.py", line 338, in connect
    (code, msg) = self.getreply()
  File "/usr/lib/python3.7/smtplib.py", line 394, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
[02/May/2019 19:30:43] "POST /manager/driver/add/ HTTP/1.1" 500 109428

I don't get why this gets, and google hasn't help much, since a lot of pages suggest to use SES, but i don't have any interest of using it since i want to use my site domain and not paying any extra to amazon for something that it should work.

A:

So, if anyone is having the same issue, just change the port to 587 and will work fine on Heroku and EC2 instances.
Also, keep in mind that my solution doesn't copy the sended email to the "send" folder of the domain.

