axllent / mailpit

An email and SMTP testing tool with API for developers
https://mailpit.axllent.org
MIT License
5.71k stars 139 forks source link

Invalid from address #294

Closed dejudicibus closed 5 months ago

dejudicibus commented 6 months ago

I installed mailpit and started it. I can see the MailPit interface on localhost:8025 as expected. Then I created a file email.txt as follows

From: sender@example.com
To: recipient@example.com
Subject: Email Subject

This is the body of the email.
It can contain multiple lines of text.

but if I call MailPit as follows

mailpit sendmail < email.txt

I get the error message

invalid from address

and no messages in the browser interface. Changing the from address to ANY real or fake address makes no change.

Platform: Windows 10 Pro with WampServer 3.2.6 64bit

axllent commented 6 months ago

That's really strange - I just tried with a copy/paste of your syntax and it works perfectly for me. I can't see any reason it would/should fail, unless potentially the txt file you created contains maybe some strange or unsupported hidden character encoding - what did you use to create the text file?

What happens if you try with this file? 1-test.txt

asuheel commented 6 months ago

I am also getting same error

invalid from address

Tried with 1-test.txt

Still same error

For refrence : I have done setup using docker-compose with this docker-compose.yaml

axllent commented 6 months ago

@bmunshi on what platform is the mailpit sendmail... being run? I assume for both of you that you're on a recent version of Mailpit too?

dejudicibus commented 6 months ago

I found out what the problem was. If I call just mailpit I get the error. To avoid the error I have to call

mailpit -s localhost:1025 -l localhost:8025

I thought that localhost was the default, whereas the default is 0.0.0.0 in both cases (1025 & 8025)

axllent commented 6 months ago

I am confused @dejudicibus - 0.0.0.0 means the Mailpit server should listen on all network interfaces which is the default (ie: not just to "localhost") which should work on Windows too, and the argument you are running is to start the Mailpit server, not to send messages via mailpit sendmail < email.txt (which is the issue you reported).

So mailpit -s localhost:1025 -l localhost:8025 starts mailpit and listens to "localhost" only (other machines in your network cannot connect), and mailpit sendmail < email.txt should then be able to send to Mailpit.

axllent commented 6 months ago

@dejudicibus & @bmunshi - I have found the cause. When using sendmail in this way (without specifying a sender's email in the command with -f), it will automatically detect your username from the system. The issue here is that Windows returns the "user" in the format hostname\username - and \ is not a valid character in an email ~ so you get the error.

I have just pushed a fix (work-around) in v1.18.2 which will fix this issue for both of you. Please confirm this works for you? Thanks.

axllent commented 6 months ago

@powerquell I don't think this is related to this issue at all. From what I see, your Mailpit requires authentication (250-AUTH LOGIN PLAIN), but you're not authenticating via telnet first before issuing theMAIL FROM.

axllent commented 6 months ago

Ahh right - sorry @powerquell, that was not obvious from your original message. Your formatting is incorrect, try MAIL FROM:<test@example.com> - the SMTP protocol requires <> around the addresses (including RCPT TO) (see this).

github-actions[bot] commented 5 months ago

This issue has been marked as stale because it has been open for 7 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because there has been no activity since being marked as stale.