This repository was archived by the owner on Dec 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-postmark-spamcheck-api.php
More file actions
75 lines (60 loc) · 1.53 KB
/
wp-postmark-spamcheck-api.php
File metadata and controls
75 lines (60 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* WP Postmark API (http://developer.postmarkapp.com/)
*
* @package WP-API-Libraries\WP-Postmark-Base\WP-Postmark-Spamcheck-API
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/* Check if class exists. */
if ( ! class_exists( 'PostMarkSpamcheckAPI' ) ) {
if ( ! class_exists( 'PostMarkBase' ) ) {
include_once( 'wp-postmark-base.php' );
}
/**
* PostMarkAPI class.
*/
class PostMarkSpamcheckAPI extends PostMarkBase {
/**
* SpamCheck URL
* Docs: http://spamcheck.postmarkapp.com/doc
*
* (default value: 'http://spamcheck.postmarkapp.com')
*
* @var string
* @access protected
*/
protected $route_uri = 'http://spamcheck.postmarkapp.com';
/**
* __construct function.
*
* @access public
* @param bool $debug (default: false) Debug.
* @return void
*/
public function __construct( $debug = false ) {
$this->args['headers'] = array(
'Accept' => 'application/json',
'Content-Type' => 'application/json',
);
$this->debug = $debug;
}
/**
* SpamCheck.
*
* @access public
* @param mixed $email The raw dump of the email to be filtered, including all headers.
* @param mixed $options Must either be "long" for a full report of processing rules, or "short" for a score request.
*/
public function spamcheck( $email, $options = 'short' ) {
$args = array(
'method' => 'POST',
'body' => array(
'email' => $email,
'options' => $options,
),
);
return $this->build_request( $args )->fetch( '/filter/' );
}
}
}