Procházet zdrojové kódy

Working on writeMime function (may make this a full encoder later)

Jordan před 11 roky
rodič
revize
3707c4710a
1 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. 12 0
      email.go

+ 12 - 0
email.go

@@ -160,7 +160,19 @@ func (e *Email) Send(addr string, a smtp.Auth) error {
 
 //writeMIME writes the quoted-printable text to the IO Writer
 func writeMIME(w io.Writer, s string) error {
+	// Basic rules (comments to be removed once this function is fully implemented)
+	// * If character is printable, it can be represented AS IS
+	// * Lines must have a max of 76 characters
+	// * Lines must not end with whitespace
+	//		- Rather, append a soft break (=) to the end of the line after the space for preservation
+	// *
 	_, err := fmt.Fprintf(w, "%s\r\n", s)
+	for _, c := range s {
+		// Check if we can just print the character
+		if (c >= '!' && c < '=') || (c >= '>' && c < '~') {
+			return nil
+		}
+	}
 	if err != nil {
 		return err
 	}