diff --git a/src/main/webapp/src/app.ts b/src/main/webapp/src/app.ts
index fa97f36fa..15bd80305 100644
--- a/src/main/webapp/src/app.ts
+++ b/src/main/webapp/src/app.ts
@@ -1,5 +1,6 @@
import { NgModule, enableProdMode } from '@angular/core'
import { RouterModule } from '@angular/router';
+import { FormsModule } from '@angular/forms';
import { rootRouterConfig } from './app/simple-java-mail-routes';
import { SimpleJavaMailApp } from './app/simple-java-mail-app';
import { BrowserModule } from '@angular/platform-browser';
@@ -37,6 +38,7 @@ require('./index.html');
imports: [
BrowserModule,
HttpModule,
+ FormsModule,
RouterModule.forRoot(rootRouterConfig, { useHash: true }),
Ng2SimplePageScrollModule.forRoot()
],
diff --git a/src/main/webapp/src/app/components/rfc/Email.ts b/src/main/webapp/src/app/components/rfc/Email.ts
new file mode 100644
index 000000000..0aacb3412
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/Email.ts
@@ -0,0 +1,10 @@
+export class Email {
+ constructor(readonly usePlainText: boolean,
+ readonly useHTMLText: boolean,
+ readonly useEmbeddedContent: boolean,
+ readonly useCalendarEvent: boolean,
+ readonly useAttachments: boolean,
+ readonly useEmailForward: boolean,
+ ) {
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategy.ts b/src/main/webapp/src/app/components/rfc/MessageStrategy.ts
new file mode 100644
index 000000000..ae691a73f
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategy.ts
@@ -0,0 +1,22 @@
+import {Email} from "./Email";
+
+export abstract class MessageStrategy {
+
+ abstract compatibleWithEmail(email: Email): boolean;
+
+ abstract determineMessageStructure(email: Email): string;
+
+ protected static emailContainsMixedContent(email: Email): boolean {
+ return email.useAttachments || email.useEmailForward;
+ }
+
+ protected static emailContainsRelatedContent(email: Email): boolean {
+ return email.useEmbeddedContent;
+ }
+
+ protected static emailContainsAlternativeContent(email: Email): boolean {
+ return (email.usePlainText ? 1 : 0) +
+ (email.useHTMLText ? 1 : 0) +
+ (email.useCalendarEvent ? 1 : 0) > 1;
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts
new file mode 100644
index 000000000..99c3fd889
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyAlternative.ts
@@ -0,0 +1,22 @@
+import {MessageStrategy} from "./MessageStrategy";
+import {Email} from "./Email";
+
+export class MessageStrategyAlternative extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return !MessageStrategy.emailContainsMixedContent(email) &&
+ !MessageStrategy.emailContainsRelatedContent(email) &&
+ MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "
" +
+ " - alternative (root)" +
+ "
" +
+ (email.usePlainText ? "- Plain text
" : "") +
+ (email.useHTMLText ? "- HTML text
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text
" : "") +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts
new file mode 100644
index 000000000..818a8a8f0
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixed.ts
@@ -0,0 +1,24 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyMixed extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return MessageStrategy.emailContainsMixedContent(email) &&
+ !MessageStrategy.emailContainsRelatedContent(email) &&
+ !MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - mixed (root)" +
+ "
" +
+ (email.usePlainText ? "- Plain text
" : "") +
+ (email.useHTMLText ? "- HTML text
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text
" : "") +
+ (email.useEmailForward ? "- forwarded email
" : "") +
+ (email.useAttachments ? "- downloadable attachments
" : "") +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts
new file mode 100644
index 000000000..c92d1e985
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedAlternative.ts
@@ -0,0 +1,28 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyMixedAlternative extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return MessageStrategy.emailContainsMixedContent(email) &&
+ !MessageStrategy.emailContainsRelatedContent(email) &&
+ MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - mixed (root)" +
+ "
" +
+ " - alternative" +
+ "
" +
+ (email.usePlainText ? "- Plain text
" : "") +
+ (email.useHTMLText ? "- HTML text
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text
" : "") +
+ "
" +
+ " " +
+ (email.useEmailForward ? "- forwarded email
" : "") +
+ (email.useAttachments ? "- downloadable attachments
" : "") +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts
new file mode 100644
index 000000000..90affae87
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelated.ts
@@ -0,0 +1,27 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyMixedRelated extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return MessageStrategy.emailContainsMixedContent(email) &&
+ MessageStrategy.emailContainsRelatedContent(email) &&
+ !MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - mixed (root)" +
+ "
" +
+ " - related" +
+ "
" +
+ " - HTML text
" +
+ " - embeddable content (ie. images)
" +
+ "
" +
+ " " +
+ (email.useEmailForward ? "- forwarded email
" : "") +
+ (email.useAttachments ? "- downloadable attachments
" : "") +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts
new file mode 100644
index 000000000..3cf47445b
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyMixedRelatedAlternative.ts
@@ -0,0 +1,34 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyMixedRelatedAlternative extends MessageStrategy {
+
+ compatibleWithEmail(email: Email): boolean {
+ return MessageStrategy.emailContainsMixedContent(email) &&
+ MessageStrategy.emailContainsRelatedContent(email) &&
+ MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - mixed (root)" +
+ "
" +
+ " - related" +
+ "
" +
+ " - alternative" +
+ "
" +
+ (email.usePlainText ? "- Plain text
" : "") +
+ (email.useHTMLText ? "- HTML text
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text
" : "") +
+ "
" +
+ " " +
+ " - embeddable content (ie. images)
" +
+ "
" +
+ " " +
+ (email.useEmailForward ? "- forwarded email
" : "") +
+ (email.useAttachments ? "- downloadable attachments
" : "") +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts
new file mode 100644
index 000000000..08a0978df
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyRelated.ts
@@ -0,0 +1,21 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyRelated extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return !MessageStrategy.emailContainsMixedContent(email) &&
+ MessageStrategy.emailContainsRelatedContent(email) &&
+ !MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - related (root)" +
+ "
" +
+ " - HTML text
" +
+ " - embeddable content (ie. images)
" +
+ "
" +
+ " " +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts b/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts
new file mode 100644
index 000000000..53644b5b6
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategyRelatedAlternative.ts
@@ -0,0 +1,25 @@
+import {Email} from "./Email";
+import {MessageStrategy} from "./MessageStrategy";
+
+export class MessageStrategyRelatedAlternative extends MessageStrategy {
+ compatibleWithEmail(email: Email): boolean {
+ return !MessageStrategy.emailContainsMixedContent(email) &&
+ MessageStrategy.emailContainsRelatedContent(email) &&
+ MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ " - related (root)
" +
+ " - alternative" +
+ "
" +
+ (email.usePlainText ? "- Plain text
" : "") +
+ (email.useHTMLText ? "- HTML text
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text
" : "") +
+ "
" +
+ " " +
+ " - embeddable content (ie. images)
" +
+ "
" +
+ " ";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/MessageStrategySimple.ts b/src/main/webapp/src/app/components/rfc/MessageStrategySimple.ts
new file mode 100644
index 000000000..ccf17d54e
--- /dev/null
+++ b/src/main/webapp/src/app/components/rfc/MessageStrategySimple.ts
@@ -0,0 +1,19 @@
+import {MessageStrategy} from "./MessageStrategy";
+import {Email} from "./Email";
+
+export class MessageStrategySimple extends MessageStrategy {
+
+ compatibleWithEmail(email: Email): boolean {
+ return !MessageStrategy.emailContainsMixedContent(email) &&
+ !MessageStrategy.emailContainsRelatedContent(email) &&
+ !MessageStrategy.emailContainsAlternativeContent(email);
+ }
+
+ public determineMessageStructure(email: Email): string {
+ return "" +
+ (email.usePlainText ? "- Plain text (root)
" : "") +
+ (email.useHTMLText ? "- HTML text (root)
" : "") +
+ (email.useCalendarEvent ? "- iCalendar text (root)
" : "") +
+ "
";
+ }
+}
diff --git a/src/main/webapp/src/app/components/rfc/rfc.html b/src/main/webapp/src/app/components/rfc/rfc.html
index f0466e90f..b62220cec 100644
--- a/src/main/webapp/src/app/components/rfc/rfc.html
+++ b/src/main/webapp/src/app/components/rfc/rfc.html
@@ -6,6 +6,7 @@ Simple Java Mail is fully RFC compliant
@@ -64,4 +65,47 @@ How is Simple Java Mail RFC compliant?
+
+
+ §
+ Explore the multipart structures used by Simple Java Mail
+
+
+
+
Configure your email:
+
+
+
+
+
+
Structure used for email:
+
+
+
diff --git a/src/main/webapp/src/app/components/rfc/rfc.ts b/src/main/webapp/src/app/components/rfc/rfc.ts
index b4d730134..58444055e 100644
--- a/src/main/webapp/src/app/components/rfc/rfc.ts
+++ b/src/main/webapp/src/app/components/rfc/rfc.ts
@@ -1,8 +1,59 @@
-import {Component} from '@angular/core';
+import {Component, Input} from '@angular/core';
+import {MessageStrategy} from "./MessageStrategy";
+import {MessageStrategyAlternative} from "./MessageStrategyAlternative";
+import {MessageStrategyMixed} from "./MessageStrategyMixed";
+import {MessageStrategyRelated} from "./MessageStrategyRelated";
+import {MessageStrategyMixedRelatedAlternative} from "./MessageStrategyMixedRelatedAlternative";
+import {MessageStrategyRelatedAlternative} from "./MessageStrategyRelatedAlternative";
+import {MessageStrategyMixedAlternative} from "./MessageStrategyMixedAlternative";
+import {MessageStrategyMixedRelated} from "./MessageStrategyMixedRelated";
+import {MessageStrategySimple} from "./MessageStrategySimple";
+import {Email} from "./Email";
@Component({
template: require('./rfc.html')
})
-
export class RfcCompliant {
+ @Input() usePlainText: boolean;
+ @Input() useHTMLText: boolean;
+ @Input() useEmbeddedContent: boolean;
+ @Input() useCalendarEvent: boolean;
+ @Input() useAttachments: boolean;
+ @Input() useEmailForward: boolean;
+
+ messageStructure: string;
+
+ private static readonly STRATEGIES: Array = [
+ new MessageStrategySimple(),
+ new MessageStrategyAlternative(),
+ new MessageStrategyRelated(),
+ new MessageStrategyMixed(),
+ new MessageStrategyMixedRelated(),
+ new MessageStrategyMixedAlternative(),
+ new MessageStrategyRelatedAlternative(),
+ new MessageStrategyMixedRelatedAlternative()
+ ];
+
+ updateMessageStructure(): void {
+ if (!this.useHTMLText) {
+ this.useEmbeddedContent = false;
+ }
+
+ this.messageStructure = RfcCompliant.determineFormalStructure(new Email(
+ this.usePlainText,
+ this.useHTMLText,
+ this.useEmbeddedContent,
+ this.useCalendarEvent,
+ this.useAttachments,
+ this.useEmailForward));
+ }
+
+ private static determineFormalStructure(email: Email): string {
+ for (const s of RfcCompliant.STRATEGIES) {
+ if (s.compatibleWithEmail(email)) {
+ return s.determineMessageStructure(email);
+ }
+ }
+ throw new Error("email config not recognized properly");
+ }
}