@@ -525,6 +525,9 @@ private async Task SendUserInviteEmailAsync(UserBasic userDisplay, string from,
525
525
var user = await _userManager . FindByIdAsync ( ( ( int ) userDisplay . Id ) . ToString ( ) ) ;
526
526
var token = await _userManager . GenerateEmailConfirmationTokenAsync ( user ) ;
527
527
528
+ // Use info from SMTP Settings if configured, otherwise set fromEmail as fallback
529
+ var senderEmail = ! string . IsNullOrEmpty ( _globalSettings . Smtp ? . From ) ? _globalSettings . Smtp . From : fromEmail ;
530
+
528
531
var inviteToken = string . Format ( "{0}{1}{2}" ,
529
532
( int ) userDisplay . Id ,
530
533
WebUtility . UrlEncode ( "|" ) ,
@@ -550,14 +553,14 @@ private async Task SendUserInviteEmailAsync(UserBasic userDisplay, string from,
550
553
var emailBody = _localizedTextService . Localize ( "user" , "inviteEmailCopyFormat" ,
551
554
//Ensure the culture of the found user is used for the email!
552
555
UmbracoUserExtensions . GetUserCulture ( to . Language , _localizedTextService , _globalSettings ) ,
553
- new [ ] { userDisplay . Name , from , message , inviteUri . ToString ( ) , fromEmail } ) ;
556
+ new [ ] { userDisplay . Name , from , message , inviteUri . ToString ( ) , senderEmail } ) ;
554
557
555
558
// This needs to be in the correct mailto format including the name, else
556
559
// the name cannot be captured in the email sending notification.
557
560
// i.e. "Some Person" <[email protected] >
558
561
var toMailBoxAddress = new MailboxAddress ( to . Name , to . Email ) ;
559
562
560
- var mailMessage = new EmailMessage ( null /*use info from smtp settings*/ , toMailBoxAddress . ToString ( ) , emailSubject , emailBody , true ) ;
563
+ var mailMessage = new EmailMessage ( senderEmail , toMailBoxAddress . ToString ( ) , emailSubject , emailBody , true ) ;
561
564
562
565
await _emailSender . SendAsync ( mailMessage , Constants . Web . EmailTypes . UserInvite , true ) ;
563
566
}
0 commit comments