Skip to content

Commit f55ee33

Browse files
authored
email: Change from to crates.io <no-reply@crates.io> (#9342)
So far we had only used `no-reply@crates.io` without a `name` in the `Mailbox`. This changes the `Mailbox` instance to use the configured `domain` as the name, which means that users will see e.g. "crates.io" as the sender instead of "no-reply@crates.io".
1 parent 0cccf61 commit f55ee33

10 files changed

+19
-17
lines changed

src/email.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use lettre::transport::file::FileTransport;
77
use lettre::transport::smtp::authentication::{Credentials, Mechanism};
88
use lettre::transport::smtp::SmtpTransport;
99
use lettre::transport::stub::StubTransport;
10-
use lettre::{Message, Transport};
10+
use lettre::{Address, Message, Transport};
1111
use rand::distributions::{Alphanumeric, DistString};
1212

1313
pub trait Email {
@@ -19,7 +19,7 @@ pub trait Email {
1919
pub struct Emails {
2020
backend: EmailBackend,
2121
pub domain: String,
22-
from: Mailbox,
22+
from: Address,
2323
}
2424

2525
const DEFAULT_FROM: &str = "noreply@crates.io";
@@ -97,13 +97,15 @@ impl Emails {
9797
self.domain,
9898
);
9999

100+
let from = Mailbox::new(Some(self.domain.clone()), self.from.clone());
101+
100102
let subject = email.subject();
101103
let body = email.body();
102104

103105
let email = Message::builder()
104106
.message_id(Some(message_id.clone()))
105107
.to(recipient.parse()?)
106-
.from(self.from.clone())
108+
.from(from)
107109
.subject(subject)
108110
.header(ContentType::TEXT_PLAIN)
109111
.body(body)?;

src/tests/routes/me/tokens/snapshots/all__routes__me__tokens__create__create_token_success-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/routes/me/tokens/create.rs
33
expression: app.emails_snapshot()
44
---
55
To: foo@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: New API token "bar" created
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/routes/me/tokens/snapshots/all__routes__me__tokens__create__create_token_with_expiry_date-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/routes/me/tokens/create.rs
33
expression: app.emails_snapshot()
44
---
55
To: foo@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: New API token "bar" created
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/routes/me/tokens/snapshots/all__routes__me__tokens__create__create_token_with_null_scopes-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/routes/me/tokens/create.rs
33
expression: app.emails_snapshot()
44
---
55
To: foo@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: New API token "bar" created
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/routes/me/tokens/snapshots/all__routes__me__tokens__create__create_token_with_scopes-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/routes/me/tokens/create.rs
33
expression: app.emails_snapshot()
44
---
55
To: foo@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: New API token "bar" created
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/snapshots/all__github_secret_scanning__github_secret_alert_revokes_token-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/github_secret_scanning.rs
33
expression: app.emails_snapshot()
44
---
55
To: foo@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: Your API token "bar" has been revoked
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/snapshots/all__owners__modify_multiple_owners-2.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/owners.rs
33
expression: app.emails_snapshot()
44
---
55
To: user2@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: Ownership invitation for "owners_multiple"
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable
@@ -17,7 +17,7 @@ wnership invitations.
1717
----------------------------------------
1818

1919
To: user3@example.com
20-
From: noreply@crates.io
20+
From: crates.io <noreply@crates.io>
2121
Subject: crates.io: Ownership invitation for "owners_multiple"
2222
Content-Type: text/plain; charset=utf-8
2323
Content-Transfer-Encoding: quoted-printable
@@ -31,7 +31,7 @@ wnership invitations.
3131
----------------------------------------
3232

3333
To: user2@example.com
34-
From: noreply@crates.io
34+
From: crates.io <noreply@crates.io>
3535
Subject: crates.io: Ownership invitation for "owners_multiple"
3636
Content-Type: text/plain; charset=utf-8
3737
Content-Transfer-Encoding: quoted-printable
@@ -45,7 +45,7 @@ wnership invitations.
4545
----------------------------------------
4646

4747
To: user3@example.com
48-
From: noreply@crates.io
48+
From: crates.io <noreply@crates.io>
4949
Subject: crates.io: Ownership invitation for "owners_multiple"
5050
Content-Type: text/plain; charset=utf-8
5151
Content-Transfer-Encoding: quoted-printable

src/tests/snapshots/all__owners__modify_multiple_owners.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/owners.rs
33
expression: app.emails_snapshot()
44
---
55
To: user2@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: Ownership invitation for "owners_multiple"
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable
@@ -17,7 +17,7 @@ wnership invitations.
1717
----------------------------------------
1818

1919
To: user3@example.com
20-
From: noreply@crates.io
20+
From: crates.io <noreply@crates.io>
2121
Subject: crates.io: Ownership invitation for "owners_multiple"
2222
Content-Type: text/plain; charset=utf-8
2323
Content-Transfer-Encoding: quoted-printable

src/tests/snapshots/all__owners__new_crate_owner.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/owners.rs
33
expression: app.emails_snapshot()
44
---
55
To: Bar@example.com
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: Ownership invitation for "foo_owner"
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: quoted-printable

src/tests/worker/snapshots/all__worker__sync_admins__sync_admins_job.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source: src/tests/worker/sync_admins.rs
33
expression: app.emails_snapshot()
44
---
55
To: existing-admin@crates.io
6-
From: noreply@crates.io
6+
From: crates.io <noreply@crates.io>
77
Subject: crates.io: Admin account changes
88
Content-Type: text/plain; charset=utf-8
99
Content-Transfer-Encoding: 7bit
@@ -18,7 +18,7 @@ Revoked admin access:
1818
----------------------------------------
1919

2020
To: obsolete-admin@crates.io
21-
From: noreply@crates.io
21+
From: crates.io <noreply@crates.io>
2222
Subject: crates.io: Admin account changes
2323
Content-Type: text/plain; charset=utf-8
2424
Content-Transfer-Encoding: 7bit

0 commit comments

Comments
 (0)