I am very new to codeigniter and postmark, is there a way on how to integrate the two?
I created a controller called cron.php and put the postmark code inside the method inbound, here's my code:
public function inbound()
{
try {
require_once '../lib/Postmark/Autoloader.php';
\Postmark\Autoloader::register();
// this file should be the target of the callback you set in your postmark account
$inbound = new \Postmark\Inbound(file_get_contents('php://input'));
$this->data['client'] = $this->client_model->get_where($m_where);
if(!empty($this->data['client']))
{
$m_insert = array('cme_username' => $inbound->FromName(),
'cme_title' => $inbound->Subject(),
'cme_message' => $inbound->TextBody(),
'cme_client' => $this->data['client']['ccl_id'],
'cme_from' => 'client',
'cme_through' => 'email',
'cme_date_sent' => date('Y-m-d H:i:s'),
'cme_admin' => 0);
$this->message_model->insert($m_insert);
}
}
catch (Exception $e) {
echo $e->getMessage();
}}
I'm also wondering if I am doing it correctly? Many thanks!
You can simply pull one of the example classes from the PostMarkApp.com website (I used this one and renamed it simply
postmark
) in the application/libraries/ directory and use it like any other CI Library. Make sure you have the proper globals defined (I defined them in application/config/config.php).application/config/config.php
application/controllers/somecontroller.php
Hope that helps!