[Logo] JForum - Powering Communities
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


JForum 2.8.3 is out with various fixes and improvements. Read all about it here

Problem with html in response emails RSS feed
Forum Index » User Forum
Author Message
jdev1


Joined: 2021/3/22
Messages: 33
Offline
Nope, now i testing with two users and they two have "Allow HTML" turned on.
Also if i change mail.messageFormat to text and change message template by removing html tags from it message comes with replaced line breaks with the <br> tag.
I seems strange. I saw replasment at Spammer.class line 245

if (this.messageFormat == 0) {
this.message.setContent(text.replaceAll("\n", "<br>"), "text/html; charset=" + charset);
} else {
this.message.setText(text);
}

Maybe some problem with that?
Also i wanted to ask you how gets config values? From table JFORUM_CONFIG or from file?
udittmer


Joined: 2013/2/21
Messages: 415
Offline
What I meant is: if at least one of them has HTML turned on, and at least one of them has it turned off.

Yes, that code section may well be the problem.

Config info is taken from the SystemGlobals.properties and jforum-custom.conf files. The DB table serves mainly as a backup of jforum-custom.conf.

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
jdev1


Joined: 2021/3/22
Messages: 33
Offline
I've also seen redefinition messageFormat at Spammer.class

private void defineUserMessage(User user) {
try {
this.templateParams.put("user", user);
String text = this.processTemplate();
int oldMessageFormat = this.messageFormat;
if (user.notifyText()) {
this.messageFormat = 0;
}

this.defineMessageText(text);
this.messageFormat = oldMessageFormat;
} catch (Exception var4) {
throw new MailException(var4);
}
}


What is the function user.notifyText()? Is it related with "Allow HTML" you wrote about earlier or something else?
udittmer


Joined: 2013/2/21
Messages: 415
Offline
Yes, that's exactly what it is.

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
jdev1


Joined: 2021/3/22
Messages: 33
Offline
Can I ask you please to compile a jar file with one change in Spammer.class for me, if it's not difficult.

Instead of
if (this.messageFormat == 0) {
this.message.setContent(text.replaceAll("\n", "<br>"), "text/html; charset=" + charset);
} else {
this.message.setText(text);
}

this:

if (this.messageFormat == 0) {
this.message.setContent(text, "text/html; charset=utf-8");
} else {
this.message.setText(text);
}

If it helps in my situation I will be very grateful. Thank you.
udittmer


Joined: 2013/2/21
Messages: 415
Offline
That doesn't look like the right fix, but don't worry - I already have a fix, and just need to test it. Patience smilie

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
jdev1


Joined: 2021/3/22
Messages: 33
Offline
Ok, i'm waiting, thanks for helping
udittmer


Joined: 2013/2/21
Messages: 415
Offline
My reading of the situation was pretty much completely wrong, including the use of the "Allow HTML" setting. The relevant setting that goes with "notifyText" is actually "Include the message contents within the notification email".

But that doesn't seem to have to do anything with the bug, which I suspect is caused by reusing the MimeMessage object. I need to look into avoiding that.

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
udittmer


Joined: 2013/2/21
Messages: 415
Offline
Turns out that there were not one, but two bugs in the mail sending code - which must have been there for ages, without anyone ever noticing them. Kudos for triggering them! smilie

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
udittmer


Joined: 2013/2/21
Messages: 415
Offline
You can try this jar file - it has the mail sending fixes.
 Filename jforum-2.8.2.jar [Disk] Download
 Description JForum 2.8.2 with all the latest fixes
 Filesize 689 Kbytes
 Downloaded:  204 time(s)


Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
jdev1


Joined: 2021/3/22
Messages: 33
Offline
Looks like that works fine. Thank you!
jdev1


Joined: 2021/3/22
Messages: 33
Offline
Hi! I have one more question.
Users complain that they do not receive notifications about new responses. In the admin panel, I send a test email and get an error like in the screenshot. After that, I send the test email again and it is sent perfectly, and notifications begin to arrive to users. And after about 1-2 hours, everything repeats. What could be the matter?
  • [Thumb - 2023-03-17_20-21-25.png]
 Filename 2023-03-17_20-21-25.png [Disk] Download
 Description No description given
 Filesize 7 Kbytes
 Downloaded:  141 time(s)

udittmer


Joined: 2013/2/21
Messages: 415
Offline
"Connection reset" frequently points to a networking issue rather than an application issue. You can add "mail.debug=true" to the mail properties on the Config page. After restarting the web app you should then see lots of debugging output in the logs; maybe that points to something.

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
jdev1


Joined: 2021/3/22
Messages: 33
Offline
I've got this message at jforum.log

2023-03-21 15:27:33,374 ERROR [AjaxAction] - net.jforum.exceptions.MailException: jakarta.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
net.jforum.exceptions.MailException: jakarta.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2476)
at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:1684)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726)
at jakarta.mail.Service.connect(Service.java:342)
at jakarta.mail.Service.connect(Service.java:222)
at net.jforum.util.mail.Spammer.dispatchMessages(Spammer.java:208)
at net.jforum.view.forum.AjaxAction.sendTestMail(AjaxAction.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.jforum.Command.process(Command.java:122)
at net.jforum.JForum.processCommand(JForum.java:269)
at net.jforum.JForum.service(JForum.java:251)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at net.jforum.csrf.CsrfFilter.doFilter(CsrfFilter.java:104)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at net.jforum.util.legacy.clickstream.ClickstreamFilter.doFilter(ClickstreamFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:610)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
at java.lang.Thread.run(Unknown Source)
Caused by: jakarta.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
... 34 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:102)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:100)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2456)
... 33 more
udittmer


Joined: 2013/2/21
Messages: 415
Offline
That's JForum logging output, which doesn't add anything to the exception you posted earlier. What you want is the JavaMail debug output.

Ping & Net - my free Android app for TCP/IP network diagnostics
[Email] [WWW]
 
Forum Index » User Forum
Go to:   
Mobile view
Powered by JForum 2.8.3 © 2023 JForum Team • Maintained by Andowson Chang and Ulf Dittmer