Plain text email?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Inkiniteo

    Plain text email?

    Hi guys. I have a script that sends the info by email, but i'd like to
    avoid the convertion to HTML by the email client or Gmail, because it
    ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
    be able to send SMTP mail and the receiver only get it in plain text.

  • Tim Williams (gmail)

    #2
    Re: Plain text email?

    On 27 Jun 2005 15:38:59 -0700, Inkiniteo <gaz082@gmail.c om> wrote:[color=blue]
    > Hi guys. I have a script that sends the info by email, but i'd like to
    > avoid the convertion to HTML by the email client or Gmail, because it
    > ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
    > be able to send SMTP mail and the receiver only get it in plain text.
    > [/color]

    Can you give a short example of how you are building the email ?

    Comment

    • Christos TZOTZIOY Georgiou

      #3
      Re: Plain text email?

      On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
      <gaz082@gmail.c om> might have written:
      [color=blue]
      >Hi guys. I have a script that sends the info by email, but i'd like to
      >avoid the convertion to HTML by the email client or Gmail, because it
      >ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
      >be able to send SMTP mail and the receiver only get it in plain text.[/color]

      Please tell us what you do more precisely:

      * do you send the "info" as an attachment using the email package?
      * do you create alternative text and HTML parts for the body?

      I have never managed to send plain text email and receive it as HTML.
      Perhaps you mean that some "smart" client does something stupid with
      your text, eg. it removes line-breaks you have in your message?


      Try this:

      import smtplib

      def send(server, from_whom, to_whom_list):
      smtp = smtplib.SMTP(se rver)
      smtp.sendmail(f rom_whom, to_whom_list,
      """From: %s
      To: %s
      Subject: test email

      This is a test.
      It has line breaks.
      Does it come as three separate lines?""")

      I tried it as

      send('localhost ', 'tzot@sil-tec.gr', ['tzot@sil-tec.gr'])

      and I had no problem. What happens for you (substitute other server and
      email addresses, obviously :) ?
      --
      TZOTZIOY, I speak England very best.
      "Dear Paul,
      please stop spamming us."
      The Corinthians

      Comment

      • Christos TZOTZIOY Georgiou

        #4
        Re: Plain text email?

        On 27 Jun 2005 15:38:59 -0700, rumours say that "Inkiniteo"
        <gaz082@gmail.c om> might have written:
        [color=blue]
        >Hi guys. I have a script that sends the info by email, but i'd like to
        >avoid the convertion to HTML by the email client or Gmail, because it
        >ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
        >be able to send SMTP mail and the receiver only get it in plain text.[/color]

        Please tell us what you do more precisely:

        * do you send the "info" as an attachment using the email package?
        * do you create alternative text and HTML parts for the body?

        I have never managed to send plain text email and receive it as HTML.
        Perhaps you mean that some "smart" client does something stupid with
        your text, eg. it removes line-breaks you have in your message?


        Try this:

        import smtplib

        def send(server, from_whom, to_whom_list):
        smtp = smtplib.SMTP(se rver)
        smtp.sendmail(f rom_whom, to_whom_list,
        """From: %s
        To: %s
        Subject: test email

        This is a test.
        It has line breaks.
        Does it come as three separate lines?""" % (from_whom,
        ", ".join(to_whom_ list))

        I tried it as

        send('localhost ', 'tzot@sil-tec.gr', ['tzot@sil-tec.gr'])

        and I had no problem. What happens for you (substitute other server and
        email addresses, obviously :) ?
        --
        TZOTZIOY, I speak England very best.
        "Dear Paul,
        please stop spamming us."
        The Corinthians

        Comment

        • Inkiniteo

          #5
          Re: Plain text email?

          Humm. I just create the message this way:

          message = 'Serie:\t\t' + str(type) + str(series) + \
          '\t\t\tUbicació n:\t\t\t' + place + '\n' + \
          'Date&Time:\t' + date

          and send it with:
          message = header + message
          server = smtplib.SMTP('l ocalhost')
          server.sendmail ('email@email.c om', email, message)
          server.quit()

          Comment

          • Christos TZOTZIOY Georgiou

            #6
            Re: Plain text email?

            On 27 Jun 2005 16:09:38 -0700, rumours say that "Inkiniteo"
            <gaz082@gmail.c om> might have written:
            [color=blue]
            >Humm. I just create the message this way:[/color]
            [color=blue]
            >message = 'Serie:\t\t' + str(type) + str(series) + \
            > '\t\t\tUbicació n:\t\t\t' + place + '\n' + \
            > 'Date&Time:\t' + date[/color]
            [color=blue]
            >and send it with:
            >message = header + message
            >server = smtplib.SMTP('l ocalhost')
            >server.sendmai l('email@email. com', email, message)
            >server.quit( )[/color]

            And what goes wrong when you see the message? (BTW you don't have a
            newline before "Ubicación: "; is it intentional?)

            Tabs are infamous confusers of email clients, unfortunately.
            --
            TZOTZIOY, I speak England very best.
            "Dear Paul,
            please stop spamming us."
            The Corinthians

            Comment

            • Philippe C. Martin

              #7
              Re: Plain text email?

              Hi,

              I had the exact opposite problem :-)

              Hope this helps

              Regards,

              Philippe



              #************** *************** *************** *************** *********
              def Mail(self,p_dat a): #data is string of text

              you = wx.GetTextFromU ser('EMAIL ADDRESS','ID')
              if len(you) == 0:
              return

              self.__m_config = Config()

              self.__m_config .Load()

              me = self.__m_config .dict['ACCOUNT']
              host = self.__m_config .dict['SMTP']
              s = smtplib.SMTP()
              s.connect(host)


              s.login(me,self .__m_config.GPW ())

              the_text = p_data
              msg = MIMEText(the_te xt)

              # *************** GET RID OF THIS LINE TO HAVE PLAIN TEXT
              *************** *************** ******
              msg.replace_hea der('Content-Type', 'text/html')
              # *************** GET RID OF THIS LINE TO HAVE PLAIN TEXT
              *************** *************** ******
              #msg.add_header ('Content-Type', 'text/html')

              msg['To'] = you
              msg['Subject'] = self.__m_title
              msg['From'] = self.__m_config .dict['FROM']
              s.sendmail(me, [you], msg.as_string() )
              self.__m_list = []



              Inkiniteo wrote:
              [color=blue]
              > Hi guys. I have a script that sends the info by email, but i'd like to
              > avoid the convertion to HTML by the email client or Gmail, because it
              > ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
              > be able to send SMTP mail and the receiver only get it in plain text.[/color]

              Comment

              • John Roth

                #8
                Re: Plain text email?

                "Inkiniteo" <gaz082@gmail.c om> wrote in message
                news:1119911939 .179743.98220@z 14g2000cwz.goog legroups.com...[color=blue]
                > Hi guys. I have a script that sends the info by email, but i'd like to
                > avoid the convertion to HTML by the email client or Gmail, because it
                > ruins all the formatting i did (with tabs, mostly). Briefing, i wanna
                > be able to send SMTP mail and the receiver only get it in plain text.[/color]

                As long as your mimetype is text/plain you should have
                minimal trouble. There's no way you can control what
                the recipient's mail client does, however.

                In particular, there are a lot of mail clients out there that
                handle tabs poorly. Outlook Express is the poster child
                for this: it ignores tabs completely, however it is by no
                means the only culprit. It's simply the most widespread one.

                In other words, use strings of spaces rather than tabs,
                and you'll probably find your messages coming out
                looking better.

                John Roth[color=blue]
                >[/color]

                Comment

                • Inkiniteo

                  #9
                  Re: Plain text email?

                  I see. So... what about sending HTML email? If i send HTML tagged text,
                  the client will be able to read it as HTML?

                  For example, if i send an email with: <header></header> <body>
                  <b>Yo!</></body> will the client read a bold Yo! ?

                  Because i can replace tabs with tables if this is possible.

                  Comment

                  • Dan Sommers

                    #10
                    Re: Plain text email?

                    On 27 Jun 2005 18:56:27 -0700,
                    "Inkiniteo" <gaz082@gmail.c om> wrote:
                    [color=blue]
                    > I see. So... what about sending HTML email? If i send HTML tagged
                    > text, the client will be able to read it as HTML?[/color]
                    [color=blue]
                    > For example, if i send an email with: <header></header> <body>
                    > <b>Yo!</></body> will the client read a bold Yo! ?[/color]

                    That depends on the client.

                    IMO, HTML belongs on web pages, not in email. YMMV.

                    Regards,
                    Dan

                    --
                    Dan Sommers
                    <http://www.tombstoneze ro.net/dan/>

                    Comment

                    • John Roth

                      #11
                      Re: Plain text email?

                      "Inkiniteo" <gaz082@gmail.c om> wrote in message
                      news:1119923787 .531336.292220@ z14g2000cwz.goo glegroups.com.. .[color=blue]
                      >I see. So... what about sending HTML email? If i send HTML tagged text,
                      > the client will be able to read it as HTML?
                      >
                      > For example, if i send an email with: <header></header> <body>
                      > <b>Yo!</></body> will the client read a bold Yo! ?
                      >
                      > Because i can replace tabs with tables if this is possible.[/color]

                      To send HTML, you definitely need a mimetype. Otherwise
                      some clients will autodiagnose as HTML and attempt to render
                      it, some won't. Strictly speaking, they shouldn't do autodetection.

                      I also agree with Dan - HTML mail is evil, and I try to avoid it
                      whenever possible. That's one of the major vectors for worms,
                      viri and simliar malware.

                      John Roth[color=blue]
                      >[/color]

                      Comment

                      • Christos TZOTZIOY Georgiou

                        #12
                        Re: Plain text email?

                        On 27 Jun 2005 18:56:27 -0700, rumours say that "Inkiniteo"
                        <gaz082@gmail.c om> might have written:
                        [color=blue]
                        >I see. So... what about sending HTML email? If i send HTML tagged text,
                        >the client will be able to read it as HTML?[/color]

                        I agree with the others that HTML is part of the web, not of the e-mail
                        system.

                        I suggest you send your "info" as an attached text file; no client will
                        mess with it. The email package is your friend for MIME messages.
                        --
                        TZOTZIOY, I speak England very best.
                        "Dear Paul,
                        please stop spamming us."
                        The Corinthians

                        Comment

                        Working...