Skip to content

BCC and CC recipients with Mailgun driver not being sent mail. #68

@cjpitch23

Description

@cjpitch23

I believe there is a bug with @adonisjs/mail package when it comes to sending bcc and/or cc recipients on a Mailgun driver. Since MIME only sends to the recipients in the to key, it doesn't send the email to those in the cc or bcc keys. I tried adding the recipients to both to and bcc and it sent the mail appropriately but the bcc recipients were not hidden. Looking into the code in the underlying Mail driver, I was able to fix the issue by updating the send() function in Mailgun.js with the following code

           Object.keys(recipients).forEach((key) => {
            if (key !== 'to') form.append('to', recipients[key])
            form.append(key, recipients[key])
        });

Here whenever the recipients are added to the form, it will append the bcc and cc recipients to the form as well.

After testing it, I was able to send emails to all of the recipients and the bcc recipients were hidden as intended.

Package version

@adonisjs/mail: 7.2.1

Node.js and npm version

Node: v14.17.0
NPM: v7.13.0

Sample Code (to reproduce the issue)

  messsage
    .from('test@test.com')
    .to('test1@test.com')
    .bcc('test2@test.com')
    .subject('This is just a test')
    .htmlView('emails/test');

Metadata

Metadata

Assignees

Labels

Type: BugThe issue has indentified a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions