keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.62k stars 2.21k forks source link

Sending Enquiry emails using mailgun recipient to {first: "Admin", last: "user"} #4793

Open kaaljabr opened 6 years ago

kaaljabr commented 6 years ago

Hi,

I am facing an issue when sending enquiries by email using mailgun. When I receive them I get into this issue:

to: { first: "Admin", last: "user" } admin@domain.com

And when I look into my inbox. I see the to field showing {

I found the issue it is here:

in transport/mailgun/processAddress.js // process { name: 'Jed Watson', email: 'user@keystonejs.com' } into 'name <email>' format if (data.name && data.email) { rtn.address = data.name + ' <' + data.email + '>'; }

It should be

rtn.address = data.name.full + ' <' + data.email + '>';

stennie commented 6 years ago

@kaaljabr This looks like issue #30 in the keystone-email package (which you've also commented on). The bug will have to be addressed there, but I'll leave this issue as a placeholder for updating the keystone-email dependency when a fix is available.

Note: it looks like the intent was to support a generic name object rather than assuming objects would be a Keystone Name field (which includes the full() virtual to concatenate the names).

Regards, Stennie

kaaljabr commented 6 years ago

Here is a workaround in case someone gets into this.

admins = admins.map(admin => {
    const {
        name: {
            full: name,
        },
        email: email,
    } = admin;
    return { name: name, email: email };
});