Search code examples
smtpgreenmail

Greenmail standalone smtp server email error


I started a standalone Greenmail SMTP server with the following configurations in root mode so that i can use 25 port,

java -Dgreenmail.setup.all -Dgreenmail.users=test1:pwd1 -Dgreenmail.hostname=10.107.45.11 -jar greenmail-standalone.jar

I am able to connect to this mail server on port 25 and send an email (from telnet as well as a java program) without any error.

But when i try to find the email I sent (using a java program), it comes out as 0 always. Received emails is always zero.

I am not sure if Greenmail can be used in this manner as a standalone server.

Can anyone please help?


Solution

  • After much of trying, I understand that the "INBOX" from which we need to fetch the messages is tied to the username and the following invocation of standalone greenmail jar gives you the emails that you expect to receive.

    We need to pass the username, password and To-email address for it work seamlessly.

    Also, specifying the ports separately makes it much easier to customize.

    java -Dgreenmail.smtp.port=25 -Dgreenmail.imap.port=143 -Dgreenmail.users=test1:[email protected] -Dgreenmail.hostname=10.107.45.11 -jar greenmail-standalone-1.5.3.jar