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

  • SEARCH
  • Home
  • 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 6631569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:33:50+00:00 2026-05-25T22:33:50+00:00

The following piece of code is formatting my email script correctly. It is placing

  • 0

The following piece of code is formatting my email script correctly. It is placing the to, from, subject, and body in the correct parts of the email. My problem is that I can’t figure out why it needs two returns and two newlines (“\r\n\r\n”) in my connect function to display the body in the email when the rest of the headers only need one CR.

def message(self):
    subject = input("What is the subject line of your message")
    headers = ["from: " + self.sendfrom,
               "to: " + self.sendto,
               "subject: " + subject,
               "content_type: text/html"]
    headers = "\r\n".join(headers)
    msg = input("type your message")
    return headers, msg

def connect(self, headers, msg):
    self.server.starttls()
    self.server.login(self.usrname,self.pswd)
    self.server.sendmail(self.sendfrom, self.sendto, headers + "\r\n\r\n" + msg)
    print("I sent the email")
    return self.server

Thanks!

  • 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-25T22:33:51+00:00Added an answer on May 25, 2026 at 10:33 pm

    Because of the standard, body must be separated from the headers with an empty line.

    A message consists of header fields and, optionally, a body. The body
    is simply a sequence of lines containing ASCII characters. It is
    separated from the headers by a null line (i.e., a line with nothing
    preceding the CRLF).

    e-mail software conforms to these standards and expects an empty line for the body. If there is no empty line, it just assumes the text is part of headers, and usually these email softwares hide most headers by default.

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

Sidebar

Related Questions

Consider the following piece of code. <html> <body> <script> var x = 5; //globally
I have the following piece of code taken from the PHP manual on the
The following piece of code works perfectly in script/console but returns the following error
The following piece of code was given to us from our instructor so we
The following piece of code is a reduced sample from the large project I'm
The following piece of code is called from a JMenuItem's ActionListener. Simply it launches
I have the following piece of code. See the two comments for the problem.
I use following piece of code to change printers port property. Problem is it
in the following piece of code, I see that when my 'description' is something
Following piece of code is from zipfile.py. self.fp.write(zinfo.FileHeader()) def FileHeader(self): header = struct.pack(structFileHeader, stringFileHeader,

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.