WebFaction
Community site: login faq

I have a contact form at shantiyoga.ca/contact with the following configurations

settings.py:

EMAIL_SUBJECT_PREFIX = 'shantiyoga.ca:'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'noahfunk@gmail.com'
EMAIL_HOST_PASSWORD = 'xxxxxxxx'
EMAIL_PORT = 587
EMAIL_USE_TLS = True

views.py:

def contact(request):

    template = 'contact.html'

    form = ContactForm(request.POST or None)    
    if form.is_valid(): # All validation rules pass

        subject = form.cleaned_data['subject']
        message = "%s\n\n%s" % (form.cleaned_data['message'], form.cleaned_data['sender'])
        cc_myself = form.cleaned_data['cc_myself']

        recipients = ['contact@shantiyoga.ca']

        sender = form.cleaned_data['sender']
        if cc_myself:
            recipients.append(sender)

        headers = {'Reply-To': form.cleaned_data['sender']}

        from django.core.mail import send_mail
        send_mail(subject,message,sender,recipients,headers)

        return redirect('/thanks/')

    return render_to_response(template, {'form': form, 'current':'contact'}, context_instance=RequestContext(request))

This works fairly well, but not optimally. My issues are that it takes some time for emails to get sent from the contact form (from my personal email...) to a webfaction mailbox, then get checked from my clients gmail account - to which I have added contact@shantiyoga.ca.

Would the preferred solution be to create an email specifically for sending mail from the sites contact form (ie: mailer@shantiyoga.ca) and use smtp.webfaction.com as EMAIL_HOST? Then the emails are sent from one webfaction address to another and managed with my clients gmail account.

I apologize if this is confusing I am a bit turned around. Thanks for your time.

asked 03 Jan '12, 21:00

shipwreck
772714
accept rate: 50%

edited 03 Jan '12, 21:01


You can send e-mail from our platform using our SMTP information and still manage incoming e-mail with gmail. You should create a mailbox on our platform and test it to verify it will work how you want. Our official documentation on sending mail from an application is here.

permanent link

answered 03 Jan '12, 21:47

johns
5.4k312
accept rate: 23%

Thanks for the link johns. I set up a development version of my sites contact form and I am trying to work through your suggestion, is it as easy as changing the settings.py file to EMAIL_HOST = 'smtp.webfaction.com' and EMAIL_HOST_USER = 'sendmail_shanti@shantiyoga.ca'? Do I need to write a script, or does django.core.mail's send_mail automagically work things out?

(05 Jan '12, 14:42) shipwreck

It doesn't appear to be working with just changing the EMAIL_ settings - but it's failing silently

(05 Jan '12, 14:45) shipwreck

EMAIL_HOST_USER should be the name of one of your mailboxes. A sample configuration is shown in our documentation: Configuring Django to Send Mail

(05 Jan '12, 16:01) seanf

After much mind-boggling I think I have things set up correctly. I am no longer seeing messages from the contact form in my personal gmail's sent folder. However, I am not seeing them in the sent folder of the roundcube mailbox that is apparently sending them?

(05 Jan '12, 19:09) shipwreck

Also, is there any way to increase the speed at which gmail picks up emails from roundcube?

(05 Jan '12, 19:16) shipwreck

However, I am not seeing them in the sent folder of the roundcube mailbox that is apparently sending them?

Storing mail in a "sent" folder is a function of the email client that sends the messages. In this case, Django's mailer is sending the messages. Django doesn't do anything to copy sent messages into IMAP folders, so you don't see them in your sent folder.

Also, is there any way to increase the speed at which gmail picks up emails from roundcube?

No, we don't have any control over how quickly email is delivered once it leaves our SMTP server (Roundcube sends via smtp.webfaction.com). Sorry!

(05 Jan '12, 19:27) seanf
showing 5 of 6 show 1 more comments
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
×261
×3

question asked: 03 Jan '12, 21:00

question was seen: 6,543 times

last updated: 05 Jan '12, 19:27

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