sendgrid-php: CC and BCC not working
CC and BCC fields aren’t working. BCC is required for integration with a 3rd party service, so multiple TO fields aren’t an option for me.
Test case:
mkdir sgtest && cd sgtest
composer init -s dev
composer require sendgrid/sendgrid 2.0.3
echo "<?php return ['username'=>'', 'password'=>'']; ?>" > cfg.php
# Add your username and password to cfg.php
curl https://gist.githubusercontent.com/lexicalbits/9669433/raw/61ee6a296734d4aaad708fdd7a482780e886e60a/gistfile1.php > run.php
php run.php
If you use the default emails in the test, you can verify the results here: http://mailinator.com/inbox.jsp?to=sgtest_to http://mailinator.com/inbox.jsp?to=sgtest_cc http://mailinator.com/inbox.jsp?to=sgtest_bcc
The test gist: https://gist.github.com/lexicalbits/9669433
My setup: Ubuntu Server 12.04 in KVM PHP from https://launchpad.net/~ondrej/+archive/php5
php -v
PHP 5.5.4-1+debphp.org~precise+1 (cli) (built: Sep 27 2013 12:39:52)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
About this issue
- Original URL
- State: closed
- Created 13 years ago
- Comments: 22 (8 by maintainers)
Thank you for the update and the code sample. Until the API changes, it might be worth throwing an exception if a web API call contains a CC or a BCC. There’s no way a user would be able to figure this restriction out on their own.
I was just bitten by this as well. I’d suggest removing the methods from your interface or have them throw an exception as suggested above. Very confusing that this doesn’t work as you would expect, especially for something that seems trivial like ‘cc’.
Ok, so this is actually by design with the way the our Web API works. I’ve talked to our team and it might be something we change in the future. Until then, you will have to go through our smtp library for this. You can do it using swiftmailer - http://swiftmailer.org/ - and this bit of example code: