Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The /mail service request always goes to localhost #161

Open
stillnet opened this issue Dec 9, 2022 · 3 comments
Open

The /mail service request always goes to localhost #161

stillnet opened this issue Dec 9, 2022 · 3 comments

Comments

@stillnet
Copy link

stillnet commented Dec 9, 2022

I'm trying to run mailslurper on a VM, and browse to it from the host machine. My VM has an IP address of 192.168.26.26. I have updated the mailslurper config file to use this IP. I have a hostname setup on my host pointing "vm" to 192.168.26.26.

When I browse to "http://vm:8025", mailslurper loads, but it does not load any mail. This is because the /mail request is failing, I can see it in Chrome dev tools. It's failing because it's trying to reach http://localhost:8085/mail?pageNumber=1&message...etc.

Why is it trying to connect on localhost? If I load mailslurper using http://192.168.26.26 everything works fine. But the "vm" hostname does resolve to 192.168.26.26, both on the host and the guest virtual machine.

image

{
	"wwwAddress": "192.168.26.26",
	"wwwPort": 8025,
	"serviceAddress": "192.168.26.26",
	"servicePort": 8085,
	"smtpAddress": "localhost",
	"smtpPort": 10025,
	"dbEngine": "SQLite",
	"dbHost": "",
	"dbPort": 0,
	"dbDatabase": "./mailslurper.db",
	"dbUserName": "",
	"dbPassword": "",
	"maxWorkers": 1000,
	"autoStartBrowser": false,
	"keyFile": "",
	"certFile": "",
	"adminKeyFile": "",
	"adminCertFile": "",
	"authenticationScheme": "",
	"authSecret": "",
	"authSalt": "",
	"authTimeoutInMinutes": 120,
	"credentials": {}
}
@stillnet stillnet changed the title The /mail request always goes to localhost The /mail service request always goes to localhost Dec 9, 2022
@stillnet
Copy link
Author

stillnet commented Dec 9, 2022

I can see that the serviceURL is set to localhost, in my brower's localstorage. If I manually edit that to be "vm" instead of "localhost", everything works fine. I searched the codebase and can't figure out where it's getting the "localhost" value from.

Edit - ok I figured out where the "localhost" value in the serviceURL is coming from. It's getting picked up from the "smtpAddress" in the config file. If I change that smtpAddress to "vm", then the web interface works fine (no more service requests to localhost). However, my applications can no longer relay mail through mailslurper, since it's no longer listening on localhost.

I'm guessing there is a bug in the code somewhere, where the serviceURL is being set from the smtpAddress, instead of being set from serviceAddress.

BTW it seems like this should be solvable using the ServicePublicURL config value, which I see referenced in the code but is not in the sample config files. I tried setting it and I could not cause it to have any effect.

@dfeyer
Copy link

dfeyer commented Jan 12, 2023

Same issue here, I have mailslurper in kubernetes with two ingress, one for the webmail and one for the service, and found now way to have the service URL to be used by the UI. ServicePublicURL is not use in the UI, nor stored in the localstorage.

@loichu
Copy link

loichu commented Aug 31, 2023

Thank you @stillnet to point out the local storage, I didn't think about it. I simply solved the issue by deleting the key in the browser, reload and then my actual config was taken. This issue seems to be solved but just think about clearing the localstorage when you change the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants