Skip to content

Commit

Permalink
[Refactor/#369] 이메일 발신자 설정 (#370)
Browse files Browse the repository at this point in the history
* refactor: 이메일 발신자 설정

* chore: 파라미터 오타 수정 form -> from
  • Loading branch information
belljun3395 authored Aug 28, 2024
1 parent ca25f1c commit 699e8b0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion email/src/main/kotlin/com/few/email/sender/EmailSender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class EmailSender<T : SendMailArgs<*, *>>(
val to = args.to
val subject = args.subject
val message = getHtml(args)
emailSendProvider.sendEmail(from, to, subject, message)
emailSendProvider.sendEmail("FEW Letter <$from>", to, subject, message)
}

abstract fun getHtml(args: T): String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class AwsSESEmailSendProvider(
private const val UTF_8 = "utf-8"
}

override fun sendEmail(form: String, to: String, subject: String, message: String) {
override fun sendEmail(from: String, to: String, subject: String, message: String) {
val destination = Destination().withToAddresses(to)
val sendMessage = Message()
.withSubject(Content().withCharset(UTF_8).withData(subject))
.withBody(Body().withHtml(Content().withCharset(UTF_8).withData(message)))

val sendEmailRequest = SendEmailRequest()
.withSource(form)
.withSource(from)
.withDestination(destination)
.withMessage(sendMessage)
.withConfigurationSetName("few-configuration-set")
Expand All @@ -41,7 +41,7 @@ class AwsSESEmailSendProvider(
log.info {
"Sending email using JavaMailSender."
}
javaEmailSendProvider.sendEmail(form, to, subject, message)
javaEmailSendProvider.sendEmail(from, to, subject, message)
}.onFailure {
log.error {
"Failed to send email using JavaMailSender."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.email.sender.provider

interface EmailSendProvider {
fun sendEmail(form: String, to: String, subject: String, message: String)
fun sendEmail(from: String, to: String, subject: String, message: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class JavaEmailSendProvider(
companion object {
private const val UTF_8 = "utf-8"
}
override fun sendEmail(form: String, to: String, subject: String, message: String) {
override fun sendEmail(from: String, to: String, subject: String, message: String) {
val sendMessage: MimeMessage = emailSender.createMimeMessage()
val helper = MimeMessageHelper(sendMessage, UTF_8)
try {
helper.setFrom(form)
helper.setFrom(from)
helper.setTo(to)
helper.setSubject(subject)
helper.setText(message, true)
Expand Down

0 comments on commit 699e8b0

Please sign in to comment.