Alright so I am trying to set a category using Sendgrid & Codeigniter. I am unable to use their STMP api so I have to do it manually but how?
This is my current code
$body = $this->load->view('mail_templates/users/SG_register_confirmation',$data, true);
$this->email->from($this->config->item('contact_email'), "Welcome!");
$this->email->to($this->config->item('to'));
$this->email->cc($this->config->item('cc'));
$this->email->subject($this->config->item('test_subject'));
$this->email->set_mailtype("html");
$this->email->message($body);
$this->email->send();
Now the email works perfectly, but I cant seem to find a way to set its category old fashioned way...
From this page, set your category using:
$json_string = array(
'to' => array(
'example1@sendgrid.com', 'example2@sendgrid.com'
),
'category' => 'test_category'
);
Then set the custom category header using the set_header
method
$this->email->set_header('x-smtpapi', json_encode($json_string));
See this page for the full list of methods supported by the Codeigniter Email
library.
You could also use SMTP
by setting Email Preferences. For eg.:
$config['smtp_host'] = 'https://api.sendgrid.com/';
$config['smtp_user'] = 'smtp_user';
$config['smtp_pass'] = 'smtp_pass';
$this->email->initialize($config);