Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC/BCC is ignored when using MIME message #81

Closed
gondo opened this issue Apr 28, 2015 · 10 comments
Closed

CC/BCC is ignored when using MIME message #81

gondo opened this issue Apr 28, 2015 · 10 comments

Comments

@gondo
Copy link

gondo commented Apr 28, 2015

I'am creating email message with SwiftMailer, than casting it toString() and passing it as 3rd parameter to sendMessage() function, as shown in documentation: https://documentation.mailgun.com/user_manual.html#sending-via-api
section: "Sending a MIME message which you pre-build yourself using a MIME library of your choice"

$result = $mgClient->sendMessage(
    $domain, array(
        'to' => 'to@example.com'
    ),
    $message->toString()
);

however cc and bcc message headers are ignored and email is sent only to to recipient.

example of my MIME message:

Message-ID: <xxx@example.com>
Date: Tue, 28 Apr 2015 14:05:30 +0200
Subject: test
From: from@example.com
To: to@example.com
Cc: cc@example.com
Bcc: bcc@example.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Mailgun-Drop-Message: yes

testing cc/bcc
@Nyholm
Copy link
Collaborator

Nyholm commented May 4, 2015

I can confirm the bug. But this is not a bug in the API client. The API client is working and sending the proper HTTP request. There is a bug on the API server.

@travelton can you confirm the bug on the API server?

Btw, this does not work (form the docs):

$mgClient->sendMessage(
    $domain, array(
        'to' => 'to@example.com'
        'cc' => 'cc@example.com'
        'bcc' => 'bcc@example.com'
    ),
    $message->toString()
);

@jessespears
Copy link
Contributor

Though it's a bit unintuitive, the behavior is consistent with our documentation's explanation: all recipients must be included in the 'to' parameter.

Your code will look like this:

$mgClient->sendMessage(
    $domain,
    array(
             'to' => ['to@example.com', 
                       'cc@example.com', 
                       'bcc@example.com']
     ),
    $message->toString()
);

I admit that the behavior is not as expected. Note that all recipients will see any bcc recipients that are in the MIME. Recipients won't see who was specified in your 'to' => [...] array, so all that's needed to keep your bccs secret is to just not specify them in the MIME.

@gondo
Copy link
Author

gondo commented May 6, 2015

@jessespears but how do you specify what recipient is CC and what is BCC if you can use only to param as in your example, and you cant specify CC/BCC in MIME?

@jessespears
Copy link
Contributor

Here's what you'll want to do:

To: specify in the 'to' param and also in the To: header of the MIME
Cc: specify in the 'to' param and also in the Cc: header of the MIME
Bcc: specify only in the 'to' param.

If you submit using a text or html field instead of MIME, each recipient will see themselves as the only recipient mentioned in their To: field in their client.
Edit: Non-MIME messages are submitted with the to, cc, and bcc fields.

@Nyholm
Copy link
Collaborator

Nyholm commented May 6, 2015

Thank you for the clarification.

Though it's a bit unintuitive, the behavior is consistent with our documentation's explanation: all recipients must be included in the 'to' parameter.

Is this true only for MIME messages?

If you submit using a text or html field instead of MIME, each recipient will see themselves as the only recipient mentioned in their To: field in their client.

I'm not too sure this is correct, or I might misunderstand you.

$result = $mgClient->sendMessage($domain, array(
            'from'    => 'Excited User <biz@example.com>',
            'to'      => ['foo@example.com', 'tobias@happyr.com'],
            'cc'      => 'baz@example.com',
            'bcc'     => 'tobias.nyholm@gmail.com',
            'subject' => 'Hello',
            'text'    => 'Testing some Mailgun awesomness!',
            'html'    => '<html>HTML version of the body</html>'
        ));

This will send an email to tobias@happyr.com mailbox and one to tobias.nyholm@gmail.com mailbox. In both mailboxes I can see the following recipients.
screen shot 2015-05-06 at 21 49 17

@jessespears
Copy link
Contributor

@Nyholm you are absolutely right. I was mistaken. The to, cc, and bcc fields are supported for the non-MIME messages. I have edited my previous comment. Thanks for catching that!

@amish-sharma-searce
Copy link

amish-sharma-searce commented Oct 15, 2021

Thank you for the clarification.

Though it's a bit unintuitive, the behavior is consistent with our documentation's explanation: all recipients must be included in the 'to' parameter.

Is this true only for MIME messages?

If you submit using a text or html field instead of MIME, each recipient will see themselves as the only recipient mentioned in their To: field in their client.

I'm not too sure this is correct, or I might misunderstand you.

$result = $mgClient->sendMessage($domain, array(
            'from'    => 'Excited User <biz@example.com>',
            'to'      => ['foo@example.com', 'tobias@happyr.com'],
            'cc'      => 'baz@example.com',
            'bcc'     => 'tobias.nyholm@gmail.com',
            'subject' => 'Hello',
            'text'    => 'Testing some Mailgun awesomness!',
            'html'    => '<html>HTML version of the body</html>'
        ));

This will send an email to tobias@happyr.com mailbox and one to tobias.nyholm@gmail.com mailbox. In both mailboxes I can see the following recipients. screen shot 2015-05-06 at 21 49 17

Why is bcc not visible in the email header? @Nyholm

@DavidGarciaCat
Copy link
Collaborator

BCC is - by definition - a blind carbon copy meaning that it is not listed when checking your email headers.

@amish-sharma-searce
Copy link

@DavidGarciaCat Not even in sender's email header?

@DavidGarciaCat
Copy link
Collaborator

Of course not, that's why it's called blind

https://duckduckgo.com/?q=meaning+of+bcc+in+email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants