Skip to content

Commit

Permalink
springboot: mjml responsive email
Browse files Browse the repository at this point in the history
  • Loading branch information
while1618 committed Dec 6, 2024
1 parent 78826a7 commit 3476641
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 749 deletions.
5 changes: 5 additions & 0 deletions backend/spring-boot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM maven:3.9.6-amazoncorretto-21-debian AS build

RUN apt-get update; apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh

WORKDIR /app

COPY pom.xml .
Expand Down
40 changes: 40 additions & 0 deletions backend/spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<spotless.version>2.43.0</spotless.version>
<google-java-format.version>1.17.0</google-java-format.version>
<exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -224,6 +225,45 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>generate verify-email.html</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>npx</executable>
<arguments>
<argument>mjml</argument>
<argument>src/main/resources/templates/email/verify-email.mjml</argument>
<argument>-o</argument>
<argument>src/main/resources/templates/email/verify-email.html</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>generate reset-password.html</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>npx</executable>
<arguments>
<argument>mjml</argument>
<argument>src/main/resources/templates/email/reset-password.mjml</argument>
<argument>-o</argument>
<argument>src/main/resources/templates/email/reset-password.html</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void sendEmail(EmailService emailService, Environment environment, User u
final var link = environment.getProperty("ui.app.url") + "/auth/reset-password?token=" + token;
final var body =
CharStreams.toString(new InputStreamReader(template, StandardCharsets.UTF_8))
.replace("$name", user.getUsername())
.replace("$link", link)
.replace("$appName", Objects.requireNonNull(environment.getProperty("app.name")));
.replace("${name}", user.getUsername())
.replace("${link}", link)
.replace("${appName}", Objects.requireNonNull(environment.getProperty("app.name")));
emailService.sendHtmlEmail(user.getEmail(), "Reset password", body);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void sendEmail(EmailService emailService, Environment environment, User u
final var link = environment.getProperty("ui.app.url") + "/auth/verify-email?token=" + token;
final var body =
CharStreams.toString(new InputStreamReader(template, StandardCharsets.UTF_8))
.replace("$name", user.getUsername())
.replace("$link", link)
.replace("$appName", Objects.requireNonNull(environment.getProperty("app.name")));
.replace("${name}", user.getUsername())
.replace("${link}", link)
.replace("${appName}", Objects.requireNonNull(environment.getProperty("app.name")));
emailService.sendHtmlEmail(user.getEmail(), "Verify email", body);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reset-password.html
verify-email.html
Loading

0 comments on commit 3476641

Please sign in to comment.