WebFaction
Community site: login faq

I've set up an email inbox named 'nova' and added a password. I added the following to my settings.py file:

EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'maxmackie'
EMAIL_HOST_PASSWORD = #my pass
EMAIL_PORT = 587

However, I get:

[Errno 111] Connection refused

From django when trying to create the connection. Could it be I have the host/port wrong?

I guess I should also post my code for sending the email:

from django.core.mail import EmailMultiAlternatives
subject = "Hello!"
from_email = "updates@example.ca"
to_email = clean['email'] # get the email from a form
body = "<html><b>This is bold</b><br><br><span style='float:right'>right</span></html>"
msg = EmailMultiAlternatives(subject, body, from_email, [to_email])
msg.send()

asked 18 Apr '12, 07:49

maxmackie
9346
accept rate: 0%

edited 18 Apr '12, 07:57


Hi,

The host and port are correct. The user should be the new one you created "nova". Also, are you running this from your webhosting server? If so, and if you're still getting this error, please submit a support ticket, and we'll take a look at it.

permanent link

answered 18 Apr '12, 08:00

todork
1.2k5
accept rate: 34%

I changed my username to 'nova' and it worked! Thanks for your help.

(18 Apr '12, 08:12) maxmackie

You are most welcome!

(18 Apr '12, 08:17) todork

Here's my code that works (plus extraneous stuff) . I don't think I specified a port though. I'm very new at all this so I can't explain it! I just found it somewhere and did some tweaking.

Django settings for myproject project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'saywot'
EMAIL_HOST_PASSWORD = 'mypasswordishere'
DEFAULT_FROM_EMAIL = 'qwerty@saywot.webfactional.com'

-------------------------------------------- from view.py

 from django.http import HttpResponse
    from django.core.mail import send_mail
    from django.core.mail import EmailMessage
    from django.core.mail import EmailMultiAlternatives
    from html import HTML

# now obscoleted
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse

from django.shortcuts import render_to_response

##

# I installed this my self - hope it can be found also I set 2.6 as version

import HTML
import cgi
import cgitb; cgitb.enable() # for debugging
import random

import datetime
import time

import sys
import os
import time
import smtplib

import xlrd 
import string
import numpy

from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders

def cdate(request):
    now = datetime.datetime.now()
    t = get_template('current_datetime.html')
    html = t.render(Context({'current_date': now}))
    return HttpResponse(html)

def cdate2(request):
    now = datetime.datetime.now()
    return render_to_response('current_datetime.html', {'current_date': now})

def hellocgi(request):

    c= "<body>"
    d=  "hello from here"

    note= '/home/saywot/webapps/xango/testdoc.txt'

    subject, from_email, to_mail = 'hello qqqqq', 'qwerty@saywot.webfactional.com', ['hellospam@gmail.com']
    text_content = 'This is an important message. xxxqqq'

    message = EmailMessage(subject, text_content, from_email,to_mail,  headers = {'Reply-To': 'another@example.com'})
    attachment = open(note, 'rb')
    message.attach(note,attachment.read(),'application/txt')

    message.send()
    a="An email was just sent to: "
    b= to_mail[0]
    return HttpResponse(a+b+ "with attached: " + note)
permanent link

answered 25 Apr '12, 21:44

darter
26134
accept rate: 14%

If you don't specify a port, the default (SMTP port 25) should be used for non-encrypted SMTP traffic. For reference, the full matrix of protocols and ports is available in our documentation.

(25 Apr '12, 22:36) ryans ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×337
×261

question asked: 18 Apr '12, 07:49

question was seen: 11,651 times

last updated: 25 Apr '12, 22:36

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM