freescout-help-desk / freescout

FreeScout — Free self-hosted help desk & shared mailbox (Zendesk / Help Scout alternative)
https://freescout.net
GNU Affero General Public License v3.0
2.9k stars 480 forks source link

Headers in messages #4181

Closed Munktells closed 2 weeks ago

Munktells commented 4 weeks ago

Since a while back ago, Freescout has starting to showing e-mail headers in new messages. It's shown above the message itself. This only happens for some messages, not all.

Any ideas what could be causing this?

PHP version: 8.2.22 FreeScout version: 1.8.148 Database: MySQL Are you using CloudFlare: No Are you using non-official modules: No

Headers in new messages

cruunnerr commented 4 weeks ago

I have exactly the same problem after I updated from 1.8.109 to 1.8.149. Like @PysX found out (and i can confirm) this happens only when the content-type of the mail is text/plain https://github.com/freescout-help-desk/freescout/issues/4155

Unfortunatley the issue was closed without any solution

freescout-help commented 4 weeks ago

@Munktells Can you send a sample email (send, not forward) at support@freescout.net. If not - send the EML file of the email.

cruunnerr commented 3 weeks ago

I sent you an eml, but unfortunately you were not able to reproduce it. Since i cannot give you access to my freescout server maybe you can try this:

With this python script I am able to reproduce the phenomenon:

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

# E-Mail Details
sender_email = "sender@domain.de"
receiver_email = "receiver@domain.de"
subject = "0000 Just a test"
body = "Body text message"

# SMTP Server Konfiguration
smtp_server = "mail.domain.de"  # Outlook SMTP Server
smtp_port = 25  # Unverschlüsselter SMTP Port

# Plaintext E-Mail Nachricht erstellen
msg = MIMEText(body, 'plain') # Note this!
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = subject

# Verbindung zum SMTP-Server aufbauen und E-Mail senden
try:
    server = smtplib.SMTP(smtp_server, smtp_port)
    server.sendmail(sender_email, receiver_email, msg.as_string())  # E-Mail senden
    print("E-Mail erfolgreich gesendet!")
except Exception as e:
    print(f"Fehler beim Senden der E-Mail: {e}")
finally:
    server.quit()  # Verbindung schließen
freescout-help commented 3 weeks ago

@cruunnerr Try to send a test email to support@freescout.net using your python script.

cruunnerr commented 3 weeks ago

I did right at this moment. thank you

@freescout-help Just want to ask if you could observe the same issue with my test mail?

Because I installed a completely fresh freescout instance with your installation bash script and the problem exists even in a fresh installation.

freescout-help commented 3 weeks ago

This must be something server or mail server specific. We could not reproduce the issue on obtained EML files or real emails. The issue need to be investigated on the server.

What mail servers are you using?

PysX commented 3 weeks ago

In my case :

cruunnerr commented 3 weeks ago

@freescout-help

In our production system we are using Microsoft exchange and the mails are only send locally. Here is where I can reproduce the issue with the python script posted above.

For further tests I just installed a fresh Ubuntu 22.04 LTS and directly installed freescout with your bash script. After that I added an email account in freescout which is hosted by ionos. Mails are fetched in freescout with POP3 protocol with user/password authentication. With SSL/TLS.

I then added a few lines to the python script and sent a test mail with an ionos account to the fresh installed freescout instance. And that results in exactly that issue. I used the same script to send a testmail (from an ionos account, too) to your support so I am wondering why the error doesn't appear to you.

import smtplib
from email.mime.text import MIMEText
import ssl

# E-Mail Details
sender_email = "xxx@xxx.de"
receiver_email = "support@freescout.net"
subject = "Test subject - Reffering to Github issue #4181"
body = "Test body text. Reffering to Github issue #4181"

# SMTP Server Konfiguration
smtp_server = "smtp.ionos.de"  # SMTP Server
smtp_port = 465  # SMTP Port für TLS
smtp_username = "xxx@xxx.de"
smtp_password = "SUPERSECUREPASSWORD"

# Plaintext E-Mail Nachricht erstellen
msg = MIMEText(body, 'plain')
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = subject

try:
    context = ssl.create_default_context()  # SSL/TLS Kontext erstellen
    with smtplib.SMTP_SSL(smtp_server, smtp_port, context=context) as server:
        server.login(smtp_username, smtp_password)  # Anmelden
        server.sendmail(sender_email, receiver_email, msg.as_string())  # E-Mail senden
    print("E-Mail erfolgreich gesendet!")
except Exception as e:
    print(f"Fehler beim Senden der E-Mail: {e}")
finally:
    server.quit()  # Verbindung schließen

Maybe some other could try to reproduce or confirm my experience

freescout-help commented 2 weeks ago

We've managed to reproduce the issue. It occurs only when POP3 is used with non-multipart emails.

Related issue: https://github.com/Webklex/php-imap/issues/386

freescout-help commented 2 weeks ago

Fixed in the master branch and will be published in the next release.

PysX commented 2 weeks ago

Thanks for finding an fixing this bug !