diff --git a/src/app/pages/system/general-settings/email/email-card/email-card.component.html b/src/app/pages/system/general-settings/email/email-card/email-card.component.html
index 755b7e7d9a1..23a1e3b88c0 100644
--- a/src/app/pages/system/general-settings/email/email-card/email-card.component.html
+++ b/src/app/pages/system/general-settings/email/email-card/email-card.component.html
@@ -28,7 +28,7 @@
{{ 'Email' | translate }}
- @if (!emailConfig?.oauth?.client_id) {
+ @if (emailConfig?.fromemail || emailConfig?.fromname) {
{{ 'From' | translate }}:
diff --git a/src/app/pages/system/general-settings/email/email-card/email-card.component.spec.ts b/src/app/pages/system/general-settings/email/email-card/email-card.component.spec.ts
index 23dae7e6bfa..5f04013c60e 100644
--- a/src/app/pages/system/general-settings/email/email-card/email-card.component.spec.ts
+++ b/src/app/pages/system/general-settings/email/email-card/email-card.component.spec.ts
@@ -92,6 +92,7 @@ describe('EmailCardComponent with Gmail OAuth', () => {
expect(itemTexts).toEqual([
'Send Mail Method: GMail OAuth',
+ 'From: Test root@truenas.local via google.com',
]);
});
});
diff --git a/src/app/pages/system/general-settings/email/email-form/email-form.component.html b/src/app/pages/system/general-settings/email/email-form/email-form.component.html
index 99cf95c5d27..c2c1e30dad6 100644
--- a/src/app/pages/system/general-settings/email/email-form/email-form.component.html
+++ b/src/app/pages/system/general-settings/email/email-form/email-form.component.html
@@ -14,20 +14,20 @@
[options]="sendMethodOptions$"
>
- @if (isSmtp) {
-
+
-
+
+ @if (isSmtp) {
{
it('saves Gmail Oauth config when user authorizes via Gmail and saves the form', async () => {
await form.fillForm({
+ 'From Email': 'newfrom@ixsystems.com',
+ 'From Name': 'Johnny',
'Send Mail Method': 'GMail OAuth',
});
@@ -169,8 +171,8 @@ describe('EmailFormComponent', () => {
await saveButton.click();
expect(api.call).toHaveBeenCalledWith('mail.update', [{
- fromemail: '',
- fromname: '',
+ fromemail: 'newfrom@ixsystems.com',
+ fromname: 'Johnny',
oauth: {
client_id: 'new_client_id',
client_secret: 'new_secret',
@@ -202,8 +204,8 @@ describe('EmailFormComponent', () => {
text: 'This is a test message from TrueNAS SCALE.',
},
{
- fromemail: '',
- fromname: '',
+ fromemail: 'from@ixsystems.com',
+ fromname: 'John Smith',
oauth: {
client_id: 'new_client_id',
client_secret: 'new_secret',
@@ -253,6 +255,8 @@ describe('EmailFormComponent', () => {
it('saves Outlook Oauth config when user authorizes via Outlook and saves the form', async () => {
await form.fillForm({
+ 'From Email': 'newfrom@ixsystems.com',
+ 'From Name': 'Johnny',
'Send Mail Method': 'Outlook OAuth',
});
@@ -263,8 +267,8 @@ describe('EmailFormComponent', () => {
await saveButton.click();
expect(api.call).toHaveBeenCalledWith('mail.update', [{
- fromemail: '',
- fromname: '',
+ fromemail: 'newfrom@ixsystems.com',
+ fromname: 'Johnny',
outgoingserver: 'smtp-mail.outlook.com',
port: 587,
security: 'TLS',
@@ -299,8 +303,8 @@ describe('EmailFormComponent', () => {
text: 'This is a test message from TrueNAS SCALE.',
},
{
- fromemail: '',
- fromname: '',
+ fromemail: 'from@ixsystems.com',
+ fromname: 'John Smith',
outgoingserver: 'smtp-mail.outlook.com',
port: 587,
security: 'TLS',
@@ -426,6 +430,8 @@ describe('EmailFormComponent', () => {
const values = await form.getValues();
expect(values).toEqual({
+ 'From Email': 'from@ixsystems.com',
+ 'From Name': 'John Smith',
'Send Mail Method': 'GMail OAuth',
});
expect(spectator.query('.oauth-message')).toHaveText('Gmail credentials have been applied.');
@@ -458,6 +464,8 @@ describe('EmailFormComponent', () => {
const values = await form.getValues();
expect(values).toEqual({
+ 'From Email': 'from@ixsystems.com',
+ 'From Name': 'John Smith',
'Send Mail Method': 'Outlook OAuth',
});
expect(spectator.query('.oauth-message')).toHaveText('Outlook credentials have been applied.');
diff --git a/src/app/pages/system/general-settings/email/email-form/email-form.component.ts b/src/app/pages/system/general-settings/email/email-form/email-form.component.ts
index 4a491b4e384..9f9d4adc034 100644
--- a/src/app/pages/system/general-settings/email/email-form/email-form.component.ts
+++ b/src/app/pages/system/general-settings/email/email-form/email-form.component.ts
@@ -68,7 +68,7 @@ export class EmailFormComponent implements OnInit {
sendMethodControl = new FormControl(MailSendMethod.Smtp, { nonNullable: true });
form = this.formBuilder.group({
- fromemail: ['', [Validators.required, emailValidator()]],
+ fromemail: ['', [emailValidator()]],
fromname: [''],
outgoingserver: [''],
port: [null as number | null, [
@@ -271,8 +271,8 @@ export class EmailFormComponent implements OnInit {
}
} else {
update = {
- fromemail: '',
- fromname: '',
+ fromemail: this.form.value.fromemail,
+ fromname: this.form.value.fromname,
oauth: {
...this.oauthCredentials as MailOauthConfig,
provider: this.sendMethodControl.value,