Krish Krish - 23 days ago 4
PHP Question

Issue processing incoming emails in mailgun

I want to process the json (recieved through post request from mailgun of incoming email).

I'm using codeigniter.

Following is a portion the json that I'm dealing with.

"log-level": "info",
"timestamp": 1475215276.814206,
"message": {
"headers": {
"to": "",
"message-id": "",
"from": "User Test <>",
"subject": "example email for testing"
"attachments": [],
"recipients": [

I do not have any problem accessing the from value
and subject value

However I'm trying to access the to and recipients with the following code, but all I'm getting is null values.

$to = $this->input->post('to');

$message_header = $this->input->post('message');
$recipients = $message_header->recipients;
$email = $recipients[0];
$email_q = filter_var($email, FILTER_SANITIZE_EMAIL);

Any help would be great.


Got the to address in the following way.

In Codeigniter: