Skip to content

Instantly share code, notes, and snippets.

@vstakhov
Created March 10, 2021 11:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vstakhov/3dda60a5638a6aefd454973bd687fc21 to your computer and use it in GitHub Desktop.
Save vstakhov/3dda60a5638a6aefd454973bd687fc21 to your computer and use it in GitHub Desktop.
@saskuu
Copy link

saskuu commented Jul 15, 2022

if sending a text/plain, the first line in mail is lost and global "content-transfer-encoding" not changing

if sending mixed (plain+html), in first part (plain) header is lost and first line is lost, and "Content-Type: text/html; charset=UTF-8" not in new line:
must be:

--------------2NuAdv3DB2BRiOvWceYV9Xp5
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

1

2

  * 1
  * 2

plain footer
--------------2NuAdv3DB2BRiOvWceYV9Xp5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>1</p>
    <p>2</p>
    <ul>
      <li>1</li>
      <li>2<br>
      </li>
    </ul>
  </body>
</html>

html footer
--------------2NuAdv3DB2BRiOvWceYV9Xp5--

but there is

2

  * 1
  * 2

plain footer
--------------2NuAdv3DB2BRiOvWceYV9Xp5Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>1</p>
    <p>2</p>
    <ul>
      <li>1</li>
      <li>2<br>
      </li>
    </ul>
  </body>
</html>

html footer
--------------2NuAdv3DB2BRiOvWceYV9Xp5--


Thunderbird

@oscarmlage
Copy link

After many attempts, I've got it working with a minor modification, I've added a newline in L76:

out_parts[#out_parts + 1] = o .. newline_s

Hope it helps!

@Aurel035
Copy link

Aurel035 commented Apr 10, 2023

After many attempts, I've got it working with a minor modification, I've added a newline in L76:

out_parts[#out_parts + 1] = o .. newline_s

Hope it helps!

If I do so, DKIM verification doesn't work anymore.

@bogdansrnd
Copy link

How can we modify this to add the plain text at the beginning of the email body? For long emails, if you add the text at the end some users might miss the message

@bogdansrnd
Copy link

Ah, one more thing. Can this be modified to add the text message to email body only if the sender is not on a list of senders?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment