katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
345 stars 336 forks source link

Outlook and Gmail don't open with proper name email #357

Closed juliengloria closed 2 years ago

juliengloria commented 3 years ago

Cannot open Outlook or Gmail app if my "to" property = ['fisrtn lastn<toto@mail.com>'] or ['toto@mail.com (fisrtn lastn)'] Only native mail application seems to work on iOS.

jfoclpf commented 2 years ago

@juliengloria sorry the late reply, but this does not seem to be a bug, since the documentation is very clear on which type of email is authorized

cordova.plugins.email.open({
    to:      'max@mustermann.de',
    cc:      'erika@mustermann.de',
    bcc:     ['john@doe.com', 'jane@doe.com'],
    subject: 'Greetings',
    body:    'How are you? Nice greetings from Leipzig'
});

If you really want to use something like that, you can have this function

function extractEmail (text) {
  return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi)[0]
}

cordova.plugins.email.open({
    to:      extractEmail('toto@mail.com (fisrtn lastn)'),
    cc:      extractEmail('fisrtn lastn<toto@mail.com>'),
    bcc:     ['john@doe.com', 'jane@doe.com'],
    subject: 'Greetings',
    body:    'How are you? Nice greetings from Leipzig'
});
jfoclpf commented 2 years ago

if you still think this is a bug, please let us know to reopen the issue