<?php
/**
 * @brief		Incoming Email Handler
 * @author		<a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
 * @copyright	(c) 2001 - 2016 Invision Power Services, Inc.
 * @license		http://www.invisionpower.com/legal/standards/
 * @package		IPS Community Suite
{subpackage}
 * @since		{date}
 * @version		SVN_VERSION_NUMBER
 */

namespace IPS\{app}\extensions\core\IncomingEmail;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
	exit;
}

/**
 * Incoming Email Handler
 */
class _{class}
{
	/**
	 * Handle email
	 *
	 * @param	\IPS\Email\Incoming	$email	The email
	 * @return	bool
	 */
	public function process( \IPS\Email\Incoming $email )
	{
		if ( ... )
		{
			// Do something with the email...
			
			/* Save attachments */
			foreach ( $files as $file )
			{
				$attachment = $file->makeAttachment('');
				
				\IPS\Db::i()->insert( 'core_attachments_map', array(
					'attachment_id'	=> $attachment['attach_id'],
					'location_key'	=> ...,
					'id1'			=> ...,
					'id2'			=> ...,
				) );
			}
		}
		
		return FALSE; // Must return false if not processing
	}
}