Skip to content

obaid/postmark-inbound-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POSTMARK INBOUND HOOK

This is a simple API wrapper for Postmark Inbound Hook (http://developer.postmarkapp.com/developer-inbound.html)

Build Status

Usage

include 'lib/postmark_inbound.php';

//load json
$inbound = New PostmarkInbound(file_get_contents('php://input'));
// or test with $inbound = New PostmarkInbound(file_get_contents(dirname(__FILE__).'/tests/fixtures/valid_http_post.json'));

/* Content */
$inbound->from(); // Bob Bobson <[email protected]>
$inbound->from_name(); // Bob Bobson if not set return false
$inbound->from_email(); // <[email protected]>

$recipients = $inbound->to();

foreach($recipients as $recipient) {
	echo $recipient->name; //if not set return false
	echo $recipient->email;
}

$undisclosed_recipients = $inbound->cc();

foreach($undisclosed_recipients as $undisclosed_recipient) {
	echo $undisclosed_recipient->name; //if not set return false
	echo $undisclosed_recipient->email;
}

$inbound->bcc();
$inbound->tag();
$inbound->message_id();
$inbound->mailbox_hash();
$inbound->reply_to();
$inbound->html_body();
$inbound->text_body();
$inbound->date();

/* Headers */
$inbound->headers();  //default to get Date
$inbound->headers('MIME-Version');
$inbound->headers('Received-SPF');
$inbound->headers('Date');

/* Spam */
$inbound->spam(); //default to get status
$inbound->spam('X-Spam-Checker-Version');
$inbound->spam('X-Spam-Score');
$inbound->spam('X-Spam-Tests');
$inbound->spam('X-Spam-Status');

/* Attachments */
$inbound->has_attachments(); //boolean
$attachments = $inbound->attachments();

$first_attachment = $attachments->get(0);
$first_attachment->name();

$second_attachment = $attachments->get(1);
$second_attachment->content_length();

$third_attachment = $attachments->get(2); // will return FALSE if it doesn't exist

foreach($attachments as $a) {
	$a->name();
	$a->content_type();
	$a->content_length();
	
	$options = array(
		'directory' => dirname(__FILE__).'/tests/fixtures/',
		'allowed_content_types' => array('image/png', 'text/html', 'text/plain'), //optionnal
		'max_content_length' => 10000 //optionnal
	);

	$a->download($options);
}

/* Get raw data */
$inbound::json();
$inbound::source();

FAQ

Bug tracker

Have a bug? Please create an issue here on GitHub!

Contributions

Thanks for your help.

Authors

Joffrey Jaffeux

Inspiration

Thx to Randy Schmidt for the original ruby wrapper

Other libraries

License

DON'T BE A DICK PUBLIC LICENSE

About

Simple API wrapper for Postmark Inbound Hook

Resources

Stars

Watchers

Forks

Packages

No packages published