@@ -81,14 +81,26 @@ func (p *sesProvider) Send(ctx context.Context, message *emailtypes.Message) (*e
8181 return nil , fmt .Errorf ("no from address specified" )
8282 }
8383
84+ // Set default from name if not provided
85+ fromName := message .FromName
86+ if fromName == "" {
87+ fromName = p .config .FromName
88+ }
89+
90+ // Format From address if name is provided
91+ fromAddress := from
92+ if fromName != "" {
93+ fromAddress = fmt .Sprintf ("%s <%s>" , fromName , from )
94+ }
95+
8496 // Validate recipients
8597 if len (message .To ) == 0 {
8698 return nil , fmt .Errorf ("no recipients specified" )
8799 }
88100
89101 // Build SES input
90102 input := & sesv2.SendEmailInput {
91- FromEmailAddress : aws .String (from ),
103+ FromEmailAddress : aws .String (fromAddress ),
92104 Destination : & types.Destination {
93105 ToAddresses : message .To ,
94106 },
@@ -108,7 +120,7 @@ func (p *sesProvider) Send(ctx context.Context, message *emailtypes.Message) (*e
108120 // Send email
109121 result , err := p .client .SendEmail (ctx , input )
110122 if err != nil {
111- p .logger .Errorw ("Failed to send email via SES" , "error" , err , "to" , message .To )
123+ p .logger .Errorw ("Failed to send email via SES" , "error" , err , "from" , fromAddress , " to" , message .To )
112124 return & emailtypes.SendResult {
113125 Success : false ,
114126 Error : err .Error (),
0 commit comments