-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
242 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
name: WildFly Mail Quickstart CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths: | ||
- 'mail/**' | ||
- '.github/workflows/quickstart_ci.yml' | ||
#on: | ||
# pull_request: | ||
# types: [opened, synchronize, reopened, ready_for_review] | ||
# paths: | ||
# - 'mail/**' | ||
# - '.github/workflows/quickstart_ci.yml' | ||
|
||
on: workflow_dispatch | ||
jobs: | ||
call-quickstart_ci: | ||
uses: ./.github/workflows/quickstart_ci.yml | ||
with: | ||
QUICKSTART_PATH: mail | ||
TEST_PROVISIONED_SERVER: true | ||
TEST_OPENSHIFT: false | ||
MATRIX_OS: '"ubuntu-20.04"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# Start apache James with the required configuration | ||
docker run -d --rm --name "apache-james" \ | ||
-p 1465:465 \ | ||
-p 1993:993 \ | ||
-p 1025:25 \ | ||
-p 1110:110 \ | ||
-p 1587:587 \ | ||
-p 1143:143 \ | ||
-v ${GITHUB_WORKSPACE}/quickstarts/mail/mail-server-conf/imapserver.xml:/root/conf/imapserver.xml \ | ||
-v ${GITHUB_WORKSPACE}/quickstarts/mail/mail-server-conf/pop3server.xml:/root/conf/pop3server.xml \ | ||
-v ${GITHUB_WORKSPACE}/quickstarts/mail/mail-server-conf/smtpserver.xml:/root/conf/smtpserver.xml \ | ||
apache/james:demo-3.8.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,12 @@ services: | |
- "1587:587" | ||
- "1143:143" | ||
volumes: | ||
- "./mail-server-conf/imapserver.xml:/root/conf/imapserver.xml" | ||
- "./mail-server-conf/pop3server.xml:/root/conf/pop3server.xml" | ||
- "./mail-server-conf/smtpserver.xml:/root/conf/smtpserver.xml" | ||
- ./mail-server-conf/imapserver.xml:/root/conf/imapserver.xml | ||
- ./mail-server-conf/pop3server.xml:/root/conf/pop3server.xml | ||
- ./mail-server-conf/smtpserver.xml:/root/conf/smtpserver.xml | ||
healthcheck: | ||
test: [ "CMD-SHELL", "/bin/james-cli -h 127.0.0.1 -p 9999 ListUsers | grep -q '[email protected]'" ] | ||
interval: 5s | ||
timeout: 1m | ||
retries: 5 | ||
start_period: 20s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ | |
package org.jboss.as.quickstarts.mail; | ||
|
||
import jakarta.annotation.Resource; | ||
import jakarta.enterprise.context.SessionScoped; | ||
import jakarta.faces.application.FacesMessage; | ||
import jakarta.faces.context.FacesContext; | ||
import jakarta.faces.view.ViewScoped; | ||
import jakarta.inject.Named; | ||
import jakarta.mail.Address; | ||
import jakarta.mail.Folder; | ||
|
@@ -31,6 +31,7 @@ | |
import jakarta.mail.internet.InternetAddress; | ||
import jakarta.mail.internet.MimeMessage; | ||
|
||
import java.io.IOException; | ||
import java.io.Serializable; | ||
|
||
/** | ||
|
@@ -51,7 +52,7 @@ | |
*/ | ||
|
||
@Named | ||
@ViewScoped | ||
@SessionScoped | ||
public class Email implements Serializable { | ||
|
||
private static final long serialVersionUID = 1544680932114626710L; | ||
|
@@ -72,7 +73,9 @@ public class Email implements Serializable { | |
private String body; | ||
|
||
private String pop3User = "[email protected]"; | ||
|
||
private String pop3Password = "1234"; | ||
|
||
private String pop3Emails; | ||
|
||
private String imapEmails; | ||
|
@@ -111,9 +114,14 @@ public void resetSmtp() { | |
public void retrievePop3() throws Exception { | ||
try { | ||
pop3Emails = retrieveEmails("pop3", pop3User, pop3Password); | ||
if (pop3Emails == null) { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
FacesMessage facesMessage = new FacesMessage("No message found."); | ||
context.addMessage(null, facesMessage); | ||
} | ||
} catch (Exception e) { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
FacesMessage facesMessage = new FacesMessage("Error retrieving emails using Pop3. " + e.getMessage()); | ||
FacesMessage facesMessage = new FacesMessage("Error retrieving emails using POP3. " + e.getMessage()); | ||
context.addMessage(null, facesMessage); | ||
} | ||
} | ||
|
@@ -127,9 +135,14 @@ public void resetPop3() { | |
public void retrieveImap() throws Exception { | ||
try { | ||
imapEmails = retrieveEmails("imap"); | ||
if (imapEmails == null) { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
FacesMessage facesMessage = new FacesMessage("No message found."); | ||
context.addMessage(null, facesMessage); | ||
} | ||
} catch (Exception e) { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
FacesMessage facesMessage = new FacesMessage("Error retrieving emails using Pop3. " + e.getMessage()); | ||
FacesMessage facesMessage = new FacesMessage("Error retrieving emails using IMAP. " + e.getMessage()); | ||
context.addMessage(null, facesMessage); | ||
} | ||
} | ||
|
@@ -138,11 +151,11 @@ public void resetImap() { | |
imapEmails = null; | ||
} | ||
|
||
private String retrieveEmails(String protocol) throws MessagingException { | ||
private String retrieveEmails(String protocol) throws MessagingException, IOException { | ||
return retrieveEmails(protocol, null, null); | ||
} | ||
|
||
private String retrieveEmails(String protocol, String user, String password) throws MessagingException { | ||
private String retrieveEmails(String protocol, String user, String password) throws MessagingException, IOException { | ||
Store store = mySession.getStore(protocol); | ||
if (user != null && !user.trim().isEmpty()) { | ||
store.connect(user, password); | ||
|
@@ -158,10 +171,6 @@ private String retrieveEmails(String protocol, String user, String password) thr | |
Message[] messages = inbox.getMessages(); | ||
|
||
if (messages.length == 0) { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
FacesMessage facesMessage = new FacesMessage("No message found for " + user); | ||
context.addMessage(null, facesMessage); | ||
|
||
return null; | ||
} | ||
|
||
|
@@ -176,6 +185,7 @@ private String retrieveEmails(String protocol, String user, String password) thr | |
sb.append("Message ").append((i + 1)).append("\n"); | ||
sb.append("From : ").append(messages[i].getFrom()[0]).append("\n"); | ||
sb.append("Subject : ").append(messages[i].getSubject()).append("\n"); | ||
sb.append("Body : ").append(messages[i].getContent().toString()).append("\n"); | ||
sb.append("Sent Date : ").append(messages[i].getSentDate()).append("\n"); | ||
sb.append("----------------------------------").append("\n"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
mail/src/test/java/org/jboss/as/quickstarts/mail/MailTestCase.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.