greenmail | Official master for the Greenmail project | TLS library
kandi X-RAY | greenmail Summary
kandi X-RAY | greenmail Summary
[GreenMail][greenmail_project_site] is an open source, intuitive and easy-to-use test suite of email servers for testing purposes. Supports SMTP, POP3, IMAP with SSL socket support, and can be run either embedded in a junit test, as a standalone Java application or as a docker container. GreenMail is the first and only library that offers a test framework for both receiving and retrieving emails from Java.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Process the request
- Write a response to the IMAP command
- Write a command response with an untagged command
- Parses the incoming mailbox request
- Converts MessageFlags to IMAP format
- Adjusts the msn number for expunged messages that were not already registered
- Process the command line
- Combines the search terms and mailbox name and mailbox name and mailbox name
- Compares two messages
- Compare two comparable objects
- Initializes the bean s properties
- Compares two servers
- Executes a command line
- Consumes the request and wait for the response
- Parses the request
- Retrieves a list of messages
- Executes the command line
- Executes the command
- Parses the request to get the quota
- Renames a mailbox
- Send a moving message
- Parses an append command
- Executes a command
- Executes a command on the inbox
- Returns an array of uids that match the given search term
- Initialize the GreenMail service
greenmail Key Features
greenmail Examples and Code Snippets
@Configuration
// since you're using @SpringBootTest annotation - it will load properties from src/test/reources/application.properties so you can put spring.mail.port=1234 there
public class MyTestMailConfig {
@Bean
public GreenM
greenMail = new GreenMail(new ServerSetup(2525, "127.0.0.1", "smtp"));
greenMail.setUser("username", "secret");
@Autowired
private MailingServiceImpl mailingServiceImpl;
@Rule
public final GreenMailRule greenMail = new GreenMailRule(ServerSetupTest.SMTP);
@Test
public void testSendMail() throws IOException {
mailingServiceImpl.sendMail("sender
No qualifying bean of type [com.radial.hostedpayments.service.MailClientService] found for dependency [com.radial.hostedpayments.service.MailClientService]: expected at least 1 bean which qualifies as autowire candidate for this dependency
docker exec -ti bash
GreenMail smtpServer = new GreenMail(new ServerSetup(8585, "0.0.0.0", "smtp"));
host: ${MAIL_SERVER_HOST:0.0.0.0}
GreenMail greenMail = new GreenMail(ServerSetup.SMTPS);
...
props.put("mail.smtp.host", ServerSetup.SMTPS.getBindAddress());
props.put("mail.smtp.port", ServerSetup.SMTPS.getPort());
props.put("mail.smtp.socketFactory.port", ServerSetup.SM
Community Discussions
Trending Discussions on greenmail
QUESTION
Is there a way how to atomically receive messages from GreenMail and then purge those messages? I don't want to receive any message more than once. Something like getReceivedMessagesAndPurge()
.
In my code, I want to write any email received by GreenMail to disk. My plan is to call GreenMail.getReceivedMessages()
let say every second and write received messages to disk. And after that I need to call GreenMail.purgeEmailFromAllMailboxes()
in order to write any message to disk only once. However there is a race condition which I don't know, how to avoid.
ANSWER
Answered 2022-Feb-20 at 13:34You could write your own MessageDeliveryHandler to do that.
QUESTION
There is an application written with Spring Boot 1.5.21. I'm asked to upgrade it to Spring Boot 2.3.4, and fix the errors the upgrade brings. Apparently, this didn't go well since I'm merely a beginner on many things. I've been able to solve some errors due to dependency changes, by googling. But the one I'm going to ask took me hours yet I didn't even see a clue of it.
Directly this is the error message shown by IntelliJ:
...ANSWER
Answered 2020-Oct-05 at 09:31The solution is simple and also really silly IMHO.
In src/test/resources/application.yml
, previously it was
QUESTION
My Spring Boot project uses JUnit 5. I'd like to setup an integration test which requires a local SMTP server to be started, so I implemented a custom extension:
...ANSWER
Answered 2020-Sep-02 at 10:11I don't think you should work with Extensions here, or in general, any "raw-level" JUnit stuff (like lifecycle methods), because you won't be able to access the application context from them, won't be able to execute any custom logic on beans and so forth.
Instead, take a look at Spring's test execution listeners abstraction
With this approach, GreenMail
will become a bean managed by spring (probably in a special configuration that will be loaded only in tests) but since it becomes a bean it will be able to load the property values and use @Value
annotation.
In the test execution listener you'll start the server before the test and stop after the test (or the whole test class if you need that - it has "hooks" for that).
One side note, make sure you mergeMode = MergeMode.MERGE_WITH_DEFAULTS
as a parameter to @TestExecutionListeners
annotation, otherwise some default behaviour (like autowiring in tests, dirty context if you have it, etc) won't work.
Update 1
Following Update 1 in the question. This won't work because the listener itself is not a spring bean, hence you can't autowire or use @Value
annotation in the listener itself.
You can try to follow this SO thread that might be helpful, however originally I meant something different:
- Make a GreenMail a bean by itself:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install greenmail
You can use greenmail like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the greenmail component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page