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

Problem starts service with runtime values #321

Closed N6REJ closed 4 months ago

N6REJ commented 4 months ago

I hope you'll be kind enough to help me out. I'm a mediocre php dev so I'm sure I'm doing something stupid. What I'm trying to do is convert from mailhog to mailpit. I've got everything working ( afaik ) except the ip keeps getting truncated during runtime. my conf file is this...

mailpitVersion = "1.18.7"
mailpitExe = "mailpit.exe"
mailpitWebRoot = "mail"
mailpitUiPort = "8025"
mailpitSmtpPort = "25"
mailpitListen = "127.0.0.1"

bundleRelease = "2024.6.22"

The file having issues is here : https://github.com/Bearsampp/sandbox/blob/mailpit/core/classes/bins/class.bin.mailpit.php This is the mailhog version which works perfectly for mailhog https://github.com/Bearsampp/sandbox/blob/mailpit/core/classes/bins/class.bin.mailhog.php This is what I see repeated in my logs prefaced by a LOT of NUL statements

time="2024/06/24 08:05:48" level=fatal msg="listen tcp: lookup 127: no such host"
time="2024/06/24 08:05:48" level=info msg="[smtpd] starting on 127:25 (no encryption)"
time="2024/06/24 08:05:48" level=info msg="[http] starting on 127:8025"

mailpit.out.log

I've attached the entire log incase it helps.

axllent commented 4 months ago

Hi there. This isn't actually Mailpit related. Have you asked this question on bearsampp which is actually what you're having issues with?

But yes, you are correct in that the startup options are not being passed correctly to Mailpit. This is however not a mailpit issue, but something in the bearsampp application.

N6REJ commented 4 months ago

@axllent hi, I'm the founder and main dev for bearsampp. I'm asking here cause I'm not sure what the proper layout is for the options. I think the issue is here https://github.com/Bearsampp/sandbox/blob/f349f0a5e82d253c3b57bc2b0462ac7cfcb06c35/core/classes/bins/class.bin.mailpit.php#L13 but idky

axllent commented 4 months ago

Ahh I see. OK, so that seems to be right, you will end up running something like mailpit.exe --listen "127.0.0.1:8025" --smtp "127.0.0.1:1025" --webroot "mail" which works perfectly when you run it manually in a terminal:

mailpit.exe --listen "127.0.0.1:8025" --smtp "127.0.0.1:1025" --webroot "mail"
INFO[2024/06/25 15:37:19] [smtpd] starting on 127.0.0.1:1025 (no encryption) 
INFO[2024/06/25 15:37:19] [http] starting on 127.0.0.1:8025            
INFO[2024/06/25 15:37:19] [http] accessible via http://127.0.0.1:8025/mail/

But your error logs imply that your commands are not being passed through to the terminal correctly, and somewhere your IP address values are getting truncated (or split by the first dot). On further inspection I see this mistake, which I am 99% sure is your issue- (you are converting the string "listen" address to an integer: https://github.com/Bearsampp/sandbox/blob/mailpit/core/classes/bins/class.bin.mailpit.php#L57C13-L57C87 - so 120.0.0.1 is becoming 127 which isn't valid.

I bet that if you fix that then you're issue is solved.

N6REJ commented 4 months ago

your faintastic!! what a rookie mistake. Thanks for taking the time to help. Bearsampp now uses mailpit instead of mailhog!

axllent commented 4 months ago

That's awesome, to both to help you solve your issue as well as you switching to Mailpit :tada:

N6REJ commented 4 months ago

I got one tiny ajax issue to figure out and then its golden. image instead of resolving the versions it's just spinning but thats not mailpits fault.

axllent commented 4 months ago

You may want to check your browser's debug tools to see requests and JavaScript errors

axllent commented 4 months ago

Oh, and it's Mailpit - not MailPit :)

N6REJ commented 4 months ago

Corrected and your officially part of the Bearsampp system now