Closed dannymatkovsky closed 4 years ago
@burlakko sadly, deprecating defaultToName
and/or toName
is not an option, please consider adding extra handler to ensure capability. LMK if nothing comes to mind, I'll tackle this over the next few days.
@burlakko thanks again for your input, this should be addressed with Release 3.3.0
Oh I actually planned to deal with it on monday, but you already got it done. Thanx!
Though I see a potential problem here.
Line 37: To = [{ Email: to, Name: toName || settings.defaultToName }];
will stick the defaultToName
even if you're using the different to
.
Consider following example
...
settings: {
defaultTo: "john.doe@ijs.to",
defaultToName: "Johnny Bravodoe",
}
...
strapi.plugins["email"].services.email.send({to: 'hanna@whatever.email', ...})
It will result into [{ Email: 'hanna@whatever.email', Name: 'Johnny Bravodoe' }]
recipient, which is obviously not what expected.
I believe if to
parameter is set the defaultToName
should not be used at all
UPD. The same also true for cc
and bcc
fields
UPD 2. Added a quick fix
All valid points. But while implementing I found the
normalizeTo
function looks inconsistent, e.g.recipients
params may be an array or a string but semantically similarsettings.defaultTo
andrecipientName
(toName
) - only a string.Also I've found out that the plugin's API is different from the native one. Native API has only
to
andsettings.defaultTo
params which may be just an email address string, an{Email: ..., Name: ...}
object or an array of strings or objects. This actually looks very flexible and simple. Maybe we should stick with this approach here? What do you think?I could rewrite this PR to make it consistent with native API, but
toName
anddefaultToName
will get depracated