Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:59:26+00:00 2026-05-22T23:59:26+00:00

# settings.py EMAIL_BACKEND = ‘django.core.mail.backends.filebased.EmailBackend’ # view.py from django.core.mail import send_mail def send_letter(request): the_text

  • 0
# settings.py
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'

# view.py
from django.core.mail import send_mail

def send_letter(request):
    the_text = 'this is a test of a really long line that has more words that could possibly fit in a single column of text.'
    send_mail('some_subject', the_text, 'me@test.com', ['me@test.com'])

The Django view code above, results in a text file that contains a broken line:

this is a test of a really long line that has more words that could possibl=
y fit in a single column of text.
-------------------------------------------------------------------------------

Anyone know how to change it so the output file doesn’t have linebreaks? Is there some setting in Django that controls this? Version 1.2 of Django.

Update – to back up a level and explain my original problem 🙂 I’m
using the django-registration app, which sends an email with an
account activation link. This link is a long URL, with a random
token at the end (30+ characters), and as a result, the line is breaking in the middle of the token.

In case the problem was using the Django’s filebased EmailBackend, I switched to the smtp backend and ran the built-in Python smtpd server, in debugging mode. This dumped my email to the console, where it was still broken.

I’m sure django-registration is working, with zillions of people using it 🙂 So it must be something I’ve done wrong or mis-configured. I just have no clue what.

Update 2 – according to a post in a Django list, it’s really the underlying Python email.MIMEText object, which, if correct, only pushes the problem back a little more. It still doesn’t tell me how to fix it. Looking at the docs, I don’t see anything that even mentions line-wrapping.

Update 3 (sigh) – I’ve ruled out it being a MIMEText object problem. I used a pure Python program and the smtplib/MIMEText to create and send a test email, and it worked fine. It also used a charset = “us-ascii”, which someone suggested was the only charset to not wrap text in MIMEText objects. I don’t know if that’s correct or not, but I did look more closely at my Django email output, and it has a charset of “utf-8”.

Could the wrong charset be the problem? And if so, how do I change it in Django?

Here’s the entire output stream from Django’s email:

---------- MESSAGE FOLLOWS ----------
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: some_subject
From: me@test.com
To: me@test.com
Date: Tue, 17 May 2011 19:58:16 -0000

this is a test of a really long line that has more words that could possibl=
y fit in a single column of text.
------------ END MESSAGE ------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:59:26+00:00Added an answer on May 22, 2026 at 11:59 pm

    You might be able to get your email client to not break on the 78 character soft limit by creating an EmailMessage object and passing in headers={‘format’: ‘flowed’} Like so:

    from django.core.mail import EmailMessage
    
    def send_letter(request):
        the_text = 'this is a test of a really long line that has more words that could possibly fit in a single column of text.'
        email = EmailMessage(
            subject='some_subject', 
            body=the_text, 
            from_email='me@test.com', 
            to=['me@test.com'],
            headers={'format': 'flowed'})
    
        email.send()
    

    If this doesn’t work, try using a non-debug smtp setup to send the file to an actual email client that renders the email according to rules defined in the email header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inserted this in settings.py: AUTHENTICATION_BACKENDS = ( 'blog.auth.backends.EmailBackend', 'django.contrib.auth.backends.ModelBackend', ) blog is
The files residing in .settings in a Dynamic Web Project are: .settings/ |-- org.eclipse.jdt.core.prefs
Are there any VC++ settings I should know about to generate better PDB files
What Visual Studio settings and .emacs macros improve the likelihood that code written on
What are optimal settings for Recycling of Application Pools in IIS7 in a shared
I have a settings file in my Winforms application called Settings.settings with a partial
I´ve tweaked the VC++ settings so that all of my actual code will go
I have some settings I need in a Javascript file -- servers to connect
I export my settings in Visual Studio and if I ever move to a
The JavaScript security settings on Internet Explorer for my customers disallow using window.external.AddFavorite, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.