x
You must log in to view that page.
emojunior

Problem with setting bcc in smtp api

I added bcc using smtpapi. However, when its sending the mail, I see that its interpreted as an array instead under email activity array(0x49a2e48)

This is the line I used to add the bcc using the smtpapiheader library.
$this->_ci->smtpapiheaderl->addFilterSetting('bcc','email',array('myname@gmail.com'));

After which i parse it as a curl parameter to https://sendgrid.com/api/mail.send.json:
x-smtpapi='.$this->_ci->smtpapiheaderl->asJSON()

Please advice if I'm doing it wrong? Or do I have to enable the bcc app?
1 person has
this question
+1
Reply

  • Jacob (Support Engineer) January 18, 2012 16:20
    Yes, if you're defining the BCC app in the smtpapi filter settings the way you are, you also have to "enable" it, as it says:
    "Please note, that if a filter is not specified in the X-SMTPAPI header, it will default to the setting of the app in the “Apps” tab on the website (either Enabled or Disabled)."

    If you're going to be using it all the time, it's simpler to enable it on the website, or via the WebAPI.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • emojunior
    Hi Jacob,

    I had it enabled, its working fine if I use this $this->_ci->smtpapiheaderl->addFilterSetting('bcc','email', 'myname@jmail.com); It actually worked even when I didn't enable it explicitly.

    But it breaks when I tired to put in the emails into an array
    $this->_ci->smtpapiheaderl->addFilterSetting('bcc','email', array('myname@gmail.com', 'myname2@gmail.com'));

    What should be the correct way to pass multiple emails to the bcc in smtp-api?

    This is what I have for the bcc json:

    filters": {"bcc": {"settings": {"enable":1,"email": ["myname@gmail.com", "myname2@gmail.com"]}}}


    I believe I could pass the to and bcc values using the webapi, but the formulation of the string to[] and bcc[] isn't as straight forward as pass them as array to the smtpheaderapi class.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Jacob (Support Engineer) January 19, 2012 14:50
    I don't believe the BCC app works with an array. On the web interface, it has only one email field. The intention of that app is for sending back to yourself a copy of all messages it's enabled on.

    To send to multiple addresses, you just need to add them in to To value. The way our system works is that is parses all of the x-smtpapi's "to" values, and sends them each a unique message, so that no one sees anyone else's addresses.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • emojunior
    I see. Its ok then I got it working using the webapi instead. Thanks.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated