EC-Nordbund / denomailer

A SMTP-Client implementation for deno (to send mails!)
https://deno.land/x/denomailer
MIT License
50 stars 16 forks source link

Randomly repeat html content #12

Closed sirowood closed 2 years ago

sirowood commented 2 years ago

Describe the bug html body sometimes send repeat content, such as: _Attend: Yes Start time: 07:00 End time: 12:00

d: Yes Start time: 07:00 End time: 12:00_

To Reproduce It seems the bug occurs randomly, and the repeat line also occurs randomly. `

Record date: ${recordDate}

Record time: ${recordTime}

Attend: ${attend ? "Yes": "No"}

Start time: ${startTime}

End time: ${endTime}

` **Expected behavior** A clear and concise description of what you expected to happen. **Logs** Provide the output of `deno --version` ``` 1.20.4 ``` **Additional context** 0.8.0 works without this bug.
mathe42 commented 2 years ago

Could you provide some code?

sirowood commented 2 years ago

Hi,

Here it is: ` Dear ${name},

Welcome onboard!

We have created a new account for you as ${roleName}

Please use the following information to login for your first time:

Email address: ${email}

Password: ${password}

Best regards,

`

Sebastian Krüger @.***> 于2022年4月13日周三 12:45写道:

Could you provide some code?

— Reply to this email directly, view it on GitHub https://github.com/EC-Nordbund/denomailer/issues/12#issuecomment-1097826443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUJJ5USMIKGSIFS74ER6VTVE2JT7ANCNFSM5TJ2WMTQ . You are receiving this because you authored the thread.Message ID: @.***>

xCykrix commented 2 years ago

I seem to have a similar case to this. Not sure if it is identical though but I have an email sent that the quotable printable seems to break. I've seen =20 in the pages before which is from the quotable printable. Been struggling to set the HTML content as some part of it always seems to break.

mailer.send({
        to: email!, // 'user@tld.com'
        from: configuration.mailer.from, // 'Notification <no-reply@tld.com>'
        subject: 'Authentication Request',
        html: this.loginEmailTemplate // new TextDecoder().decode(Deno.readFileSync('./templates/email.html'));
          .replace('_inject0', `https://${configuration.server.domain}/user/authenticate/callback/${eid}/${loginCode}`)
          .replace('_inject1', `https://${configuration.server.domain}/user/fraud/${eid}/${fraudCode}`)
          .replace('_inject2', `https://${configuration.server.domain}/user/unsubscribe/${eid}/${unsubscribeCode}`),
      });

image image image image

HTML: https://gist.github.com/xCykrix/00a71d6aaf400630910ed3e0de90b17b Pic 1/2 are email.html Pic 3/4 are the other file.

mathe42 commented 2 years ago

Yes I think it is the encoding but I have problems seeing why... Spaces (=20) are only encoding before a linebreak. When you remove all whitespace before linebreaks this should be fine!?

xCykrix commented 2 years ago

If the HTML is minified to absolutely no excess whitespace (one line) it sends in the expected format, but that isn't really viable from a development standpoint to keep it minified across development and production. I have absolutely no experience with quotable printable to think why it is breaking between sending and delivery. It renders fine as an HTML file but once it is encoded and sent it breaks down somewhere along the way.

xCykrix commented 2 years ago

Added the "View Original" from Gmail to see if maybe that will shed some light. Seems like potentially some of the equals in the HTML code are causing the issue? Very far out of my realm of expertise but I see href=3D"..." where fields like href="..." normally should be.

mathe42 commented 2 years ago

= is encoded to =3D thats fine.

mathe42 commented 2 years ago

I found 1 Bug. but it is still not fixed :D

mathe42 commented 2 years ago

OK found the bugs. Now it should be fine. Will release in the next 10 min just want to test some more...

xCykrix commented 2 years ago

I'll keep an eye out for it. Thank you! Thought I was going crazy because I couldn't figure out if it was an issue in the HTML or not haha.

mathe42 commented 2 years ago

released as 0.16.0

mathe42 commented 2 years ago

2 Bugs:

  1. Somehow linebreaks got missinterpreted (I think I encoded them as required) so enabeling better encoding of linebreaks
  2. Encoding chars < 16 (for example \n=10 to =A and not to =0A)
  3. Spaces at file end where encoded to =20 and that was later encoded to =3D20 so the = was encoded what was bad...
xCykrix commented 2 years ago

@mathe42 image

v0.16.0 made additional encoding errors it seems. Added original message content at https://gist.github.com/xCykrix/00a71d6aaf400630910ed3e0de90b17b#file-new-original-message

mathe42 commented 2 years ago

could you send that mail with

await client.connect({
  hostname: 'smtp.ethereal.email',
  username: 'ivy.schneider17@ethereal.email',
  password: '7ycUTX366ZZeamxy9D',
  port: 587
})

I couldn't reproduce that. And please tell me the output of deno --version

mathe42 commented 2 years ago

image

Looks fine to me... https://ethereal.email/messages/6262ad5e0d45a72544d523d7/14

the plain text version is displayed...

mathe42 commented 2 years ago

I think I know the problem and I fixed it in de65208c259280bbeafbdb2ba7ab9d32e10ab2b6. Hope 0.16.1 fixes it for you. Is a client encoding problem I think. The way how you implement the decoding of quoted printable the problem could be automaticly fixed.

xCykrix commented 2 years ago

Creating my own inbox with Ethereal and sending it via Ethereal gives the expected outcome (also sent inbound to the account via my SMTP server), but if I send it to Gmail or Outlook it has encoding errors. 0.16.1 did not resolve the issue. I'll try to send it via Gmail SMTP to see if perhaps it will have a different result.

Also: deno 1.21.0 (release, x86_64-unknown-linux-gnu) v8 10.0.139.17 typescript 4.6.2

mathe42 commented 2 years ago

created new issue for that will look into it tomorrow. But at least some bugs are fixed ;D