Coder Social home page Coder Social logo

Comments (11)

Vest avatar Vest commented on August 29, 2024

I have run integration tests, as was specified in the documentation. All emails have the "From:" field. E.g.:

Date: Mon, 13 Apr 2015 17:50:02 +0200 (CEST)
From: Me <[email protected]>
To: John Doe <[email protected]>

Could you please tell us how to reproduce the issue?

from fakesmtp.

baal avatar baal commented on August 29, 2024

Thank you for reply.
Please run this.

import java.io.*;
import java.net.*;

public class SMTPTest {
    public static void main(String[] args) {
        try {
            try (Socket so = new Socket("127.0.0.1", 25)) {
                try (DataOutputStream send = new DataOutputStream(so.getOutputStream())) {
                    try (BufferedReader recv = new BufferedReader(new InputStreamReader(so.getInputStream()))) {
                        String msg;
                        msg = "HELO 127.0.0.1\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "MAIL FROM: [email protected]\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "RCPT TO: [email protected]\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "RCPT TO: [email protected]\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "RCPT TO: [email protected]\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "DATA\r\n"
                            + "From: =?ISO-2022-JP?B?GyRCJCIkJCQmJCgkKhsoQg==?= <[email protected]>\r\n"
                            + "Subject: =?ISO-2022-JP?B?GyRCJCIkJCQmJCgkKhsoQg==?=\r\n"
                            + "To: [email protected], [email protected], [email protected]\r\n"
                            + "Content-Type: text/plain; charset=ISO-2022-JP\r\n"
                            + "Content-Transfer-Encoding: 7bit\r\n"
                            + "MIME-Version: 1.0\r\n"
                            + "Date: Fri, 12 Apr 2015 12:00:00 +0900\r\n"
                            + "Message-ID: TEST\r\n"
                            + "\r\n"
                            + "TEST\r\n"
                            + ".\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                        msg = "QUIT.\r\n";
                        send.writeBytes(msg);
                        System.out.println(msg);
                        msg = recv.readLine();
                        System.out.println(msg);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

from fakesmtp.

Vest avatar Vest commented on August 29, 2024

I had to add this part right before "DATA":

msg = recv.readLine();
System.out.println(msg);
msg = "DATA\r\n" ...

Otherwise, I get java.net.SocketException: Software caused connection abort: recv failed.
I have found out that if you put the "Date" line in DATA right before "From", the sender email is displayed. However, what I couldn't figure out yet is why the "Date" field is not shown in the resulted eml-file.
Could you please verify my workaround?
workaround

from fakesmtp.

caarmen avatar caarmen commented on August 29, 2024

I confirm that if there are multiple recipients (multiple RCPT TO commands), the first header of the message data is lost. It could be "From:" or another header, depending on the mail client. This doesn't happen if there is just one RCPT TO command.

from fakesmtp.

caarmen avatar caarmen commented on August 29, 2024

One recipient:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 192.168.1.4 ESMTP SubEthaSMTP null
helo [email protected]
250 192.168.1.4
mail from: [email protected]
250 Ok
rcpt to: [email protected]
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
Foo: bar
Foo: baz
From: [email protected]
To: [email protected]
Subject: test

asfd asfd


.
250 Ok
quit
221 Bye

Results in this mail (all ok):

Foo: bar
Foo: baz
From: [email protected]
To: [email protected]
Subject: test

asfd asfd

Two recipients:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 192.168.1.4 ESMTP SubEthaSMTP null
helo [email protected]
250 192.168.1.4
mail from: [email protected]
250 Ok
rcpt to: [email protected]
250 Ok
rcpt to: [email protected]
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
Foo: bar
Foo: baz
From: [email protected]
To: [email protected]
Subject: test

asfd asfd


.
250 Ok
quit
221 Bye

Results in this mail, missing the "Foo: bar" header:

Foo: baz
From: [email protected]
To: [email protected]
Subject: test

asfd asfd

from fakesmtp.

caarmen avatar caarmen commented on August 29, 2024

If I modify the pom.xml to use version 3.1.7 of the subethasmtp library (instead of 3.1.6), the issue goes away.

from fakesmtp.

caarmen avatar caarmen commented on August 29, 2024

Looks like it's fixed in this commit of subethasmtp:
voodoodyne/subethasmtp@34e8a14#diff-15d4579aba4b63fa6c644f58d6af4692R45

By this change in ReceivedHeaderStream.java:

        StringBuilder header = new StringBuilder();
        header.append("Received: from " + heloHost + " (" + constructTcpInfo(host) + ")\r\n");
-       header.append("        by " + whoami + " with SMTP");
+       header.append("        by " + whoami + "\r\n");
+       header.append("        with SMTP");
        if (softwareName != null)
            header.append(" (" + softwareName + ")");

from fakesmtp.

Vest avatar Vest commented on August 29, 2024

@caarmen, can you prepare a small pull request with the new pom.xml file?

from fakesmtp.

caarmen avatar caarmen commented on August 29, 2024

Pull request created: #28

from fakesmtp.

Nilhcem avatar Nilhcem commented on August 29, 2024

Many thanks to everyone for having found and contributed to this issue.
I will see what I can do this week end.
You are right, best option would be to completely remove the ability to restart the server, as the missing header is a bigger issue.

from fakesmtp.

Nilhcem avatar Nilhcem commented on August 29, 2024

FakeSMTP 2.0 is now released with subethasmtp 3.1.7.
http://nilhcem.github.io/FakeSMTP/

It should fix the issue.

from fakesmtp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.