Skip to content

Commit

Permalink
chore: add from_name for sending emails
Browse files Browse the repository at this point in the history
  • Loading branch information
thevaibhav-dixit committed Feb 22, 2024
1 parent 1475778 commit 78e3473
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/notifications/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ app:
fcm:
google_application_credentials_path: "./config/notifications/fake_service_account.json"
# email_executor:
# enabled: false
# smtp:
# username: ""
# from_email: ""
# from_name: ""
# relay: ""
# port: 587
# kratos_import:
Expand Down
2 changes: 2 additions & 0 deletions core/notifications/src/email_executor/smtp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct SmtpConfig {
#[serde(default)]
pub from_email: String,
#[serde(default)]
pub from_name: String,
#[serde(default)]
pub relay: String,
#[serde(default = "default_smtp_port")]
pub port: u16,
Expand Down
4 changes: 3 additions & 1 deletion core/notifications/src/email_executor/smtp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use error::*;
pub struct SmtpClient {
client: AsyncSmtpTransport<Tokio1Executor>,
from_email: String,
from_name: String,
}

impl SmtpClient {
Expand All @@ -29,6 +30,7 @@ impl SmtpClient {
Ok(Self {
client,
from_email: config.from_email,
from_name: config.from_name,
})
}

Expand All @@ -38,7 +40,7 @@ impl SmtpClient {
recipient_addr: GaloyEmailAddress,
) -> Result<(), SmtpError> {
let email = Message::builder()
.from(Mailbox::new(None, self.from_email.parse()?))
.from(Mailbox::new(Some(self.from_name), self.from_email.parse()?))
.to(Mailbox::new(None, recipient_addr.into_inner().parse()?))
.subject(msg.subject)
.header(ContentType::TEXT_HTML)
Expand Down

0 comments on commit 78e3473

Please sign in to comment.