Version Description
- 2017-12-24
- New: Sendgrid API & Client Version 6
- New: Add email log 'send to' column
- Fix: fallback emails on hosting require the '-f' parameter
- Fix: Using hostname insted of an IP
- Fix: Remove mailgun test folder ( virustotal issue )
- Fix: Additional bugs collected from support tickets.
- Added: added filters to from_name and from_email filters (local connection)
- change hostname extrect logic
Download this release
Release Info
Developer | yehudah |
Plugin | Post SMTP Mailer/Email Log |
Version | 1.8.1 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.8.1
- Postman/Postman-Email-Log/PostmanEmailLogController.php +3 -1
- Postman/Postman-Email-Log/PostmanEmailLogService.php +4 -2
- Postman/Postman-Email-Log/PostmanEmailLogView.php +4 -1
- Postman/Postman-Mail/PostmanDefaultModuleTransport.php +4 -6
- Postman/Postman-Mail/PostmanSendGridMailEngine.php +85 -51
- Postman/Postman-Mail/Zend-1.12.10/Mail.php +3 -1
- Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php +1 -1
- Postman/Postman-Mail/Zend-1.12.10/Mail/Transport/Smtp.php +1 -1
- Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FilterTest.php +0 -386
- Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunTest.php +0 -44
- Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunZlibTest.php +0 -79
- Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/appveyor.yml +0 -39
- Postman/Postman-Mail/sendgrid-php-3.2.0/CHANGELOG.md +0 -36
- Postman/Postman-Mail/sendgrid-php-3.2.0/MIT.LICENSE +0 -15
- Postman/Postman-Mail/sendgrid-php-3.2.0/README.md +0 -958
- Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid.php +0 -156
- Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Email.php +0 -637
- Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Exception.php +0 -14
- Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Response.php +0 -40
- Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.editorconfig +0 -0
- Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.gitignore +0 -0
- Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.travis.yml +0 -0
- Postman/Postman-Mail/sendgrid/composer.json +5 -0
- Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php +1 -1
- Postman/PostmanUtils.php +13 -5
- postman-smtp.php +2 -2
- readme.txt +13 -2
- style/postman-email-log.css +6 -0
Postman/Postman-Email-Log/PostmanEmailLogController.php
CHANGED
@@ -43,6 +43,8 @@ class PostmanEmailLogController {
|
|
43 |
$this,
|
44 |
'on_admin_init',
|
45 |
) );
|
|
|
|
|
46 |
}
|
47 |
if ( is_admin() ) {
|
48 |
$actionName = self::RESEND_MAIL_AJAX_SLUG;
|
@@ -390,7 +392,7 @@ class PostmanEmailLogController {
|
|
390 |
</select>
|
391 |
</div>
|
392 |
<div class="form-control" style="padding: 0 5px 0 5px;">
|
393 |
-
<button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter', Postman::TEXT_DOMAIN ); ?></button>
|
394 |
</div>
|
395 |
<div class="form-control">
|
396 |
<button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', Postman::TEXT_DOMAIN ); ?></button>
|
43 |
$this,
|
44 |
'on_admin_init',
|
45 |
) );
|
46 |
+
|
47 |
+
|
48 |
}
|
49 |
if ( is_admin() ) {
|
50 |
$actionName = self::RESEND_MAIL_AJAX_SLUG;
|
392 |
</select>
|
393 |
</div>
|
394 |
<div class="form-control" style="padding: 0 5px 0 5px;">
|
395 |
+
<button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter/Search', Postman::TEXT_DOMAIN ); ?></button>
|
396 |
</div>
|
397 |
<div class="form-control">
|
398 |
<button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', Postman::TEXT_DOMAIN ); ?></button>
|
Postman/Postman-Email-Log/PostmanEmailLogService.php
CHANGED
@@ -160,14 +160,16 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) {
|
|
160 |
$message .= "\r\n" . __( 'You are welcome to post a support issue.', Postman::TEXT_DOMAIN );
|
161 |
$message .= "\r\n" . __( 'The log to paste with your support issue:', Postman::TEXT_DOMAIN ) . "\r\n";
|
162 |
|
|
|
|
|
163 |
if ( $log->statusMessage && ! empty( $log->statusMessage ) ) {
|
164 |
-
mail(
|
165 |
}
|
166 |
|
167 |
preg_match_all( '/(.*)From/s', $log->sessionTranscript, $matches );
|
168 |
|
169 |
if ( isset( $matches[1][0] ) && ! empty( $matches[1][0] ) && strpos( strtolower( $matches[1][0] ), 'error' ) !== false ) {
|
170 |
-
mail(
|
171 |
}
|
172 |
}
|
173 |
|
160 |
$message .= "\r\n" . __( 'You are welcome to post a support issue.', Postman::TEXT_DOMAIN );
|
161 |
$message .= "\r\n" . __( 'The log to paste with your support issue:', Postman::TEXT_DOMAIN ) . "\r\n";
|
162 |
|
163 |
+
$to_email = get_bloginfo( 'admin_email' );
|
164 |
+
$domain = get_bloginfo( 'url' );
|
165 |
if ( $log->statusMessage && ! empty( $log->statusMessage ) ) {
|
166 |
+
mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', Postman::TEXT_DOMAIN ), $message . $log->statusMessage, null, "-f{$to_email}" );
|
167 |
}
|
168 |
|
169 |
preg_match_all( '/(.*)From/s', $log->sessionTranscript, $matches );
|
170 |
|
171 |
if ( isset( $matches[1][0] ) && ! empty( $matches[1][0] ) && strpos( strtolower( $matches[1][0] ), 'error' ) !== false ) {
|
172 |
+
mail( $to_email, "{$domain}: " . __( 'Post SMTP session transcript error', Postman::TEXT_DOMAIN ), $message . $log->sessionTranscript, null, "-f{$to_email}" );
|
173 |
}
|
174 |
}
|
175 |
|
Postman/Postman-Email-Log/PostmanEmailLogView.php
CHANGED
@@ -55,6 +55,7 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
55 |
*/
|
56 |
function column_default( $item, $column_name ) {
|
57 |
switch ( $column_name ) {
|
|
|
58 |
case 'date' :
|
59 |
case 'status' :
|
60 |
return $item [ $column_name ];
|
@@ -159,6 +160,7 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
159 |
$columns = array(
|
160 |
'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
|
161 |
'title' => _x( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ),
|
|
|
162 |
'status' => __( 'Status', Postman::TEXT_DOMAIN ),
|
163 |
'date' => _x( 'Delivery Time', 'When was this email sent?', Postman::TEXT_DOMAIN ),
|
164 |
);
|
@@ -363,9 +365,10 @@ class PostmanEmailLogView extends WP_List_Table {
|
|
363 |
/* Translators: where %s indicates the relative time from now */
|
364 |
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime );
|
365 |
}
|
366 |
-
|
367 |
$flattenedPost = array(
|
368 |
// the post title must be escaped as they are displayed in the HTML output
|
|
|
369 |
'title' => esc_html( $post->post_title ),
|
370 |
// the post status must be escaped as they are displayed in the HTML output
|
371 |
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
|
55 |
*/
|
56 |
function column_default( $item, $column_name ) {
|
57 |
switch ( $column_name ) {
|
58 |
+
case 'sent_to' :
|
59 |
case 'date' :
|
60 |
case 'status' :
|
61 |
return $item [ $column_name ];
|
160 |
$columns = array(
|
161 |
'cb' => '<input type="checkbox" />', // Render a checkbox instead of text
|
162 |
'title' => _x( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ),
|
163 |
+
'sent_to' => __( 'Sent To', Postman::TEXT_DOMAIN ),
|
164 |
'status' => __( 'Status', Postman::TEXT_DOMAIN ),
|
165 |
'date' => _x( 'Delivery Time', 'When was this email sent?', Postman::TEXT_DOMAIN ),
|
166 |
);
|
365 |
/* Translators: where %s indicates the relative time from now */
|
366 |
$date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime );
|
367 |
}
|
368 |
+
$meta_values = get_post_meta( $post->ID );
|
369 |
$flattenedPost = array(
|
370 |
// the post title must be escaped as they are displayed in the HTML output
|
371 |
+
'sent_to' => sanitize_email( $meta_values ['to_header'] [0] ),
|
372 |
'title' => esc_html( $post->post_title ),
|
373 |
// the post status must be escaped as they are displayed in the HTML output
|
374 |
'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )),
|
Postman/Postman-Mail/PostmanDefaultModuleTransport.php
CHANGED
@@ -23,7 +23,7 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) {
|
|
23 |
parent::init();
|
24 |
// From email and name
|
25 |
// If we don't have a name from the input headers
|
26 |
-
$this->fromName = 'WordPress';
|
27 |
|
28 |
/*
|
29 |
* If we don't have an email from the input headers default to wordpress@$sitename
|
@@ -34,12 +34,10 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) {
|
|
34 |
*/
|
35 |
|
36 |
// Get the site domain and get rid of www.
|
37 |
-
$
|
38 |
-
|
39 |
-
$sitename = substr ( $sitename, 4 );
|
40 |
-
}
|
41 |
|
42 |
-
$this->fromEmail = 'wordpress@' . $sitename;
|
43 |
}
|
44 |
public function isConfiguredAndReady() {
|
45 |
return false;
|
23 |
parent::init();
|
24 |
// From email and name
|
25 |
// If we don't have a name from the input headers
|
26 |
+
$this->fromName = apply_filters( 'wp_mail_from_name', 'WordPress' );
|
27 |
|
28 |
/*
|
29 |
* If we don't have an email from the input headers default to wordpress@$sitename
|
34 |
*/
|
35 |
|
36 |
// Get the site domain and get rid of www.
|
37 |
+
$site_url = get_bloginfo( 'url' );
|
38 |
+
$sitename = strtolower ( PostmanUtils::getHost( $site_url ) );
|
|
|
|
|
39 |
|
40 |
+
$this->fromEmail = apply_filters( 'wp_mail_from', 'wordpress@' . $sitename );
|
41 |
}
|
42 |
public function isConfiguredAndReady() {
|
43 |
return false;
|
Postman/Postman-Mail/PostmanSendGridMailEngine.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
3 |
|
4 |
-
require_once 'sendgrid
|
5 |
|
6 |
/**
|
7 |
* Sends mail with the SendGrid API
|
@@ -17,7 +18,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
17 |
// the result
|
18 |
private $transcript;
|
19 |
|
20 |
-
private $
|
21 |
private $apiKey;
|
22 |
|
23 |
/**
|
@@ -33,7 +34,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
33 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
34 |
|
35 |
// create the Message
|
36 |
-
$this->
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -47,100 +48,111 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
47 |
// add the Postman signature - append it to whatever the user may have set
|
48 |
if ( ! $options->isStealthModeEnabled() ) {
|
49 |
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
50 |
-
$this->
|
51 |
}
|
52 |
|
53 |
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
54 |
foreach ( ( array ) $message->getHeaders() as $header ) {
|
55 |
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
56 |
-
$this->
|
57 |
}
|
58 |
|
59 |
// if the caller set a Content-Type header, use it
|
60 |
$contentType = $message->getContentType();
|
61 |
if ( ! empty( $contentType ) ) {
|
62 |
-
$this->logger->debug( '
|
63 |
-
$this->email->addHeader( 'Content-Type', $contentType );
|
64 |
}
|
65 |
|
66 |
// add the From Header
|
67 |
$sender = $message->getFromAddress();
|
68 |
-
{
|
69 |
-
$senderEmail = $sender->getEmail();
|
70 |
-
$senderName = $sender->getName();
|
71 |
-
assert( ! empty( $senderEmail ) );
|
72 |
-
$this->email->setFrom( $senderEmail );
|
73 |
-
if ( ! empty( $senderName ) ) {
|
74 |
-
$this->email->setFromName( $senderName );
|
75 |
-
}
|
76 |
-
// now log it
|
77 |
-
$sender->log( $this->logger, 'From' );
|
78 |
-
}
|
79 |
|
80 |
-
|
81 |
-
$
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
// add the to recipients
|
|
|
84 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
85 |
$recipient->log( $this->logger, 'To' );
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
// add the cc recipients
|
90 |
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
91 |
$recipient->log( $this->logger, 'Cc' );
|
92 |
-
$this->
|
93 |
}
|
94 |
|
95 |
// add the bcc recipients
|
96 |
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
97 |
$recipient->log( $this->logger, 'Bcc' );
|
98 |
-
$this->
|
99 |
-
}
|
100 |
-
|
101 |
-
// add the reply-to
|
102 |
-
$replyTo = $message->getReplyTo();
|
103 |
-
// $replyTo is null or a PostmanEmailAddress object
|
104 |
-
if ( isset( $replyTo ) ) {
|
105 |
-
$this->email->setReplyTo( $replyTo->format() );
|
106 |
-
}
|
107 |
-
|
108 |
-
// add the date
|
109 |
-
$date = $message->getDate();
|
110 |
-
if ( ! empty( $date ) ) {
|
111 |
-
$this->email->setDate( $message->getDate() );
|
112 |
}
|
113 |
|
114 |
// add the messageId
|
115 |
$messageId = $message->getMessageId();
|
116 |
if ( ! empty( $messageId ) ) {
|
117 |
-
$this->
|
118 |
}
|
119 |
|
120 |
// add the subject
|
121 |
if ( null !== $message->getSubject() ) {
|
122 |
-
$
|
123 |
}
|
124 |
|
125 |
// add the message content
|
126 |
-
|
127 |
-
|
128 |
if ( ! empty( $textPart ) ) {
|
129 |
$this->logger->debug( 'Adding body as text' );
|
130 |
-
$
|
131 |
}
|
132 |
-
|
|
|
133 |
if ( ! empty( $htmlPart ) ) {
|
134 |
$this->logger->debug( 'Adding body as html' );
|
135 |
-
$
|
136 |
-
}
|
137 |
}
|
138 |
|
139 |
// add attachments
|
140 |
$this->logger->debug( 'Adding attachments' );
|
141 |
-
$this->addAttachmentsToMail( $message );
|
142 |
|
143 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
try {
|
145 |
|
146 |
if ( $this->logger->isDebug() ) {
|
@@ -152,17 +164,27 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
152 |
if ( $this->logger->isDebug() ) {
|
153 |
$this->logger->debug( 'Sending mail' );
|
154 |
}
|
155 |
-
|
|
|
156 |
if ( $this->logger->isInfo() ) {
|
157 |
$this->logger->info( );
|
158 |
}
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
161 |
-
$this->transcript .= print_r( $
|
162 |
} catch ( SendGrid\Exception $e ) {
|
163 |
$this->transcript = $e->getMessage();
|
164 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
165 |
-
$this->transcript .= print_r( $
|
166 |
throw $e;
|
167 |
}
|
168 |
}
|
@@ -181,12 +203,24 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
|
181 |
$attArray = $attachments;
|
182 |
}
|
183 |
// otherwise WordPress sends an array
|
|
|
184 |
foreach ( $attArray as $file ) {
|
185 |
if ( ! empty( $file ) ) {
|
186 |
$this->logger->debug( 'Adding attachment: ' . $file );
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
}
|
|
|
|
|
190 |
}
|
191 |
|
192 |
// return the SMTP session transcript
|
1 |
<?php
|
2 |
+
|
3 |
if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) {
|
4 |
|
5 |
+
require_once 'sendgrid/sendgrid-php.php';
|
6 |
|
7 |
/**
|
8 |
* Sends mail with the SendGrid API
|
18 |
// the result
|
19 |
private $transcript;
|
20 |
|
21 |
+
private $personalization;
|
22 |
private $apiKey;
|
23 |
|
24 |
/**
|
34 |
$this->logger = new PostmanLogger( get_class( $this ) );
|
35 |
|
36 |
// create the Message
|
37 |
+
$this->personalization = new SendGrid\Personalization();
|
38 |
}
|
39 |
|
40 |
/**
|
48 |
// add the Postman signature - append it to whatever the user may have set
|
49 |
if ( ! $options->isStealthModeEnabled() ) {
|
50 |
$pluginData = apply_filters( 'postman_get_plugin_metadata', null );
|
51 |
+
$this->personalization->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) );
|
52 |
}
|
53 |
|
54 |
// add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html
|
55 |
foreach ( ( array ) $message->getHeaders() as $header ) {
|
56 |
$this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) );
|
57 |
+
$this->personalization->addHeader( $header ['name'], $header ['content'] );
|
58 |
}
|
59 |
|
60 |
// if the caller set a Content-Type header, use it
|
61 |
$contentType = $message->getContentType();
|
62 |
if ( ! empty( $contentType ) ) {
|
63 |
+
$this->logger->debug( 'Some header keys are reserved. You may not include any of the following reserved headers: x-sg-id, x-sg-eid, received, dkim-signature, Content-Type, Content-Transfer-Encoding, To, From, Subject, Reply-To, CC, BCC.' );
|
|
|
64 |
}
|
65 |
|
66 |
// add the From Header
|
67 |
$sender = $message->getFromAddress();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
$senderEmail = ! empty( $sender->getEmail() ) ? $sender->getEmail() : $options->getMessageSenderEmail();
|
70 |
+
$senderName = ! empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName();
|
71 |
+
|
72 |
+
$from = new SendGrid\Email( $senderName, $senderEmail );
|
73 |
+
|
74 |
+
// now log it
|
75 |
+
$sender->log( $this->logger, 'From' );
|
76 |
|
77 |
// add the to recipients
|
78 |
+
$counter = 0;
|
79 |
foreach ( ( array ) $message->getToRecipients() as $recipient ) {
|
80 |
$recipient->log( $this->logger, 'To' );
|
81 |
+
if ( $counter == 0 ) {
|
82 |
+
$to = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
|
83 |
+
$this->personalization->addTo( $to );
|
84 |
+
} else {
|
85 |
+
$email = new SendGrid\Email($recipient->getName(), $recipient->getEmail());
|
86 |
+
$this->personalization->addTo( $email );
|
87 |
+
}
|
88 |
+
|
89 |
+
$counter++;
|
90 |
}
|
91 |
|
92 |
// add the cc recipients
|
93 |
foreach ( ( array ) $message->getCcRecipients() as $recipient ) {
|
94 |
$recipient->log( $this->logger, 'Cc' );
|
95 |
+
$this->personalization->addCc( $recipient->getEmail(), $recipient->getName() );
|
96 |
}
|
97 |
|
98 |
// add the bcc recipients
|
99 |
foreach ( ( array ) $message->getBccRecipients() as $recipient ) {
|
100 |
$recipient->log( $this->logger, 'Bcc' );
|
101 |
+
$this->personalization->addBcc( $recipient->getEmail(), $recipient->getName() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
// add the messageId
|
105 |
$messageId = $message->getMessageId();
|
106 |
if ( ! empty( $messageId ) ) {
|
107 |
+
$this->personalization->addHeader( 'message-id', $messageId );
|
108 |
}
|
109 |
|
110 |
// add the subject
|
111 |
if ( null !== $message->getSubject() ) {
|
112 |
+
$subject = $message->getSubject();
|
113 |
}
|
114 |
|
115 |
// add the message content
|
116 |
+
|
117 |
+
$textPart = $message->getBodyTextPart();
|
118 |
if ( ! empty( $textPart ) ) {
|
119 |
$this->logger->debug( 'Adding body as text' );
|
120 |
+
$content = new SendGrid\Content("text/plain", $textPart);
|
121 |
}
|
122 |
+
|
123 |
+
$htmlPart = $message->getBodyHtmlPart();
|
124 |
if ( ! empty( $htmlPart ) ) {
|
125 |
$this->logger->debug( 'Adding body as html' );
|
126 |
+
$content = new SendGrid\Content("text/html", $htmlPart);
|
|
|
127 |
}
|
128 |
|
129 |
// add attachments
|
130 |
$this->logger->debug( 'Adding attachments' );
|
|
|
131 |
|
132 |
+
$mail = new SendGrid\Mail($from, $subject, $to, $content);
|
133 |
+
$mail->addPersonalization($this->personalization);
|
134 |
+
|
135 |
+
|
136 |
+
// add the reply-to
|
137 |
+
$replyTo = $message->getReplyTo();
|
138 |
+
// $replyTo is null or a PostmanEmailAddress object
|
139 |
+
if ( isset( $replyTo ) ) {
|
140 |
+
$reply_to = new SendGrid\ReplyTo( $replyTo->getEmail(), $replyTo->getName() );
|
141 |
+
$mail->setReplyTo($reply_to);
|
142 |
+
}
|
143 |
+
|
144 |
+
$attachments = $this->addAttachmentsToMail( $message );
|
145 |
+
|
146 |
+
foreach ( $attachments as $index => $attachment ) {
|
147 |
+
$attach = new SendGrid\Attachment();
|
148 |
+
$attach->setContent($attachment['content']);
|
149 |
+
$attach->setType($attachment['type']);
|
150 |
+
$attach->setFilename($attachment['file_name']);
|
151 |
+
$attach->setDisposition("attachment");
|
152 |
+
$attach->setContentId($attachment['id']);
|
153 |
+
$mail->addAttachment($attach);
|
154 |
+
}
|
155 |
+
|
156 |
try {
|
157 |
|
158 |
if ( $this->logger->isDebug() ) {
|
164 |
if ( $this->logger->isDebug() ) {
|
165 |
$this->logger->debug( 'Sending mail' );
|
166 |
}
|
167 |
+
|
168 |
+
$response = $sendgrid->client->mail()->send()->post($mail);
|
169 |
if ( $this->logger->isInfo() ) {
|
170 |
$this->logger->info( );
|
171 |
}
|
172 |
+
|
173 |
+
$response_body = json_decode( $response->body() );
|
174 |
+
|
175 |
+
if ( isset( $response_body->errors[0]->message ) ) {
|
176 |
+
$this->transcript = $response_body->errors[0]->message;
|
177 |
+
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
178 |
+
$this->transcript .= print_r( $mail, true );
|
179 |
+
throw new Exception( $response_body->errors[0]->message );
|
180 |
+
}
|
181 |
+
$this->transcript = print_r( $response->body(), true );
|
182 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
183 |
+
$this->transcript .= print_r( $mail, true );
|
184 |
} catch ( SendGrid\Exception $e ) {
|
185 |
$this->transcript = $e->getMessage();
|
186 |
$this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS;
|
187 |
+
$this->transcript .= print_r( $mail, true );
|
188 |
throw $e;
|
189 |
}
|
190 |
}
|
203 |
$attArray = $attachments;
|
204 |
}
|
205 |
// otherwise WordPress sends an array
|
206 |
+
$attachments = array();
|
207 |
foreach ( $attArray as $file ) {
|
208 |
if ( ! empty( $file ) ) {
|
209 |
$this->logger->debug( 'Adding attachment: ' . $file );
|
210 |
+
|
211 |
+
$file_name = basename( $file );
|
212 |
+
$file_parts = explode( '.', $file_name );
|
213 |
+
$attachments[] = array(
|
214 |
+
'content' => base64_encode( file_get_contents( $file ) ),
|
215 |
+
'type' => mime_content_type( $file ),
|
216 |
+
'file_name' => $file_name,
|
217 |
+
'disposition' => 'attachment',
|
218 |
+
'id' => $file_parts[0],
|
219 |
+
);
|
220 |
}
|
221 |
}
|
222 |
+
|
223 |
+
return $attachments;
|
224 |
}
|
225 |
|
226 |
// return the SMTP session transcript
|
Postman/Postman-Mail/Zend-1.12.10/Mail.php
CHANGED
@@ -1176,7 +1176,9 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message
|
|
1176 |
if ($transport === null) {
|
1177 |
if (! self::$_defaultTransport instanceof Postman_Zend_Mail_Transport_Abstract) {
|
1178 |
require_once 'Zend/Mail/Transport/Sendmail.php';
|
1179 |
-
|
|
|
|
|
1180 |
} else {
|
1181 |
$transport = self::$_defaultTransport;
|
1182 |
}
|
1176 |
if ($transport === null) {
|
1177 |
if (! self::$_defaultTransport instanceof Postman_Zend_Mail_Transport_Abstract) {
|
1178 |
require_once 'Zend/Mail/Transport/Sendmail.php';
|
1179 |
+
|
1180 |
+
$replyTo = self::getDefaultReplyTo();
|
1181 |
+
$transport = new Postman_Zend_Mail_Transport_Sendmail("-f{$replyTo['email']}");
|
1182 |
} else {
|
1183 |
$transport = self::$_defaultTransport;
|
1184 |
}
|
Postman/Postman-Mail/Zend-1.12.10/Mail/Protocol/Smtp.php
CHANGED
@@ -205,7 +205,7 @@ class Postman_Zend_Mail_Protocol_Smtp extends Postman_Zend_Mail_Protocol_Abstrac
|
|
205 |
$this->_expect(220, 180);
|
206 |
|
207 |
stream_context_set_option($this->_socket, 'ssl', 'verify_peer', false);
|
208 |
-
|
209 |
stream_context_set_option($this->_socket, 'ssl', 'allow_self_signed', true);
|
210 |
|
211 |
if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
|
205 |
$this->_expect(220, 180);
|
206 |
|
207 |
stream_context_set_option($this->_socket, 'ssl', 'verify_peer', false);
|
208 |
+
stream_context_set_option($this->_socket, 'ssl', 'verify_peer_name', false);
|
209 |
stream_context_set_option($this->_socket, 'ssl', 'allow_self_signed', true);
|
210 |
|
211 |
if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
|
Postman/Postman-Mail/Zend-1.12.10/Mail/Transport/Smtp.php
CHANGED
@@ -120,7 +120,7 @@ class Postman_Zend_Mail_Transport_Smtp extends Postman_Zend_Mail_Transport_Abstr
|
|
120 |
if (isset($config['name'])) {
|
121 |
$this->_name = $config['name'];
|
122 |
} else {
|
123 |
-
$this->_name = PostmanUtils::
|
124 |
}
|
125 |
|
126 |
if (isset($config['port'])) {
|
120 |
if (isset($config['name'])) {
|
121 |
$this->_name = $config['name'];
|
122 |
} else {
|
123 |
+
$this->_name = PostmanUtils::getServerName();
|
124 |
}
|
125 |
|
126 |
if (isset($config['port'])) {
|
Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FilterTest.php
DELETED
@@ -1,386 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
use Clue\StreamFilter;
|
4 |
-
|
5 |
-
class FilterTest extends PHPUnit_Framework_TestCase
|
6 |
-
{
|
7 |
-
public function testAppendSimpleCallback()
|
8 |
-
{
|
9 |
-
$stream = $this->createStream();
|
10 |
-
|
11 |
-
StreamFilter\append($stream, function ($chunk) {
|
12 |
-
return strtoupper($chunk);
|
13 |
-
});
|
14 |
-
|
15 |
-
fwrite($stream, 'hello');
|
16 |
-
fwrite($stream, 'world');
|
17 |
-
rewind($stream);
|
18 |
-
|
19 |
-
$this->assertEquals('HELLOWORLD', stream_get_contents($stream));
|
20 |
-
|
21 |
-
fclose($stream);
|
22 |
-
}
|
23 |
-
|
24 |
-
public function testAppendNativePhpFunction()
|
25 |
-
{
|
26 |
-
$stream = $this->createStream();
|
27 |
-
|
28 |
-
StreamFilter\append($stream, 'strtoupper');
|
29 |
-
|
30 |
-
fwrite($stream, 'hello');
|
31 |
-
fwrite($stream, 'world');
|
32 |
-
rewind($stream);
|
33 |
-
|
34 |
-
$this->assertEquals('HELLOWORLD', stream_get_contents($stream));
|
35 |
-
|
36 |
-
fclose($stream);
|
37 |
-
}
|
38 |
-
|
39 |
-
public function testAppendChangingChunkSize()
|
40 |
-
{
|
41 |
-
$stream = $this->createStream();
|
42 |
-
|
43 |
-
StreamFilter\append($stream, function ($chunk) {
|
44 |
-
return str_replace(array('a','e','i','o','u'), '', $chunk);
|
45 |
-
});
|
46 |
-
|
47 |
-
fwrite($stream, 'hello');
|
48 |
-
fwrite($stream, 'world');
|
49 |
-
rewind($stream);
|
50 |
-
|
51 |
-
$this->assertEquals('hllwrld', stream_get_contents($stream));
|
52 |
-
|
53 |
-
fclose($stream);
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testAppendReturningEmptyStringWillNotPassThrough()
|
57 |
-
{
|
58 |
-
$stream = $this->createStream();
|
59 |
-
|
60 |
-
StreamFilter\append($stream, function ($chunk) {
|
61 |
-
return '';
|
62 |
-
});
|
63 |
-
|
64 |
-
fwrite($stream, 'hello');
|
65 |
-
fwrite($stream, 'world');
|
66 |
-
rewind($stream);
|
67 |
-
|
68 |
-
$this->assertEquals('', stream_get_contents($stream));
|
69 |
-
|
70 |
-
fclose($stream);
|
71 |
-
}
|
72 |
-
|
73 |
-
public function testAppendEndEventCanBeBufferedOnClose()
|
74 |
-
{
|
75 |
-
if (PHP_VERSION < 5.4) $this->markTestSkipped('Not supported on legacy PHP');
|
76 |
-
|
77 |
-
$stream = $this->createStream();
|
78 |
-
|
79 |
-
StreamFilter\append($stream, function ($chunk = null) {
|
80 |
-
if ($chunk === null) {
|
81 |
-
// this signals the end event
|
82 |
-
return '!';
|
83 |
-
}
|
84 |
-
return $chunk . ' ';
|
85 |
-
}, STREAM_FILTER_WRITE);
|
86 |
-
|
87 |
-
$buffered = '';
|
88 |
-
StreamFilter\append($stream, function ($chunk) use (&$buffered) {
|
89 |
-
$buffered .= $chunk;
|
90 |
-
return '';
|
91 |
-
});
|
92 |
-
|
93 |
-
fwrite($stream, 'hello');
|
94 |
-
fwrite($stream, 'world');
|
95 |
-
|
96 |
-
fclose($stream);
|
97 |
-
|
98 |
-
$this->assertEquals('hello world !', $buffered);
|
99 |
-
}
|
100 |
-
|
101 |
-
public function testAppendEndEventWillBeCalledOnRemove()
|
102 |
-
{
|
103 |
-
$stream = $this->createStream();
|
104 |
-
|
105 |
-
$ended = false;
|
106 |
-
$filter = StreamFilter\append($stream, function ($chunk = null) use (&$ended) {
|
107 |
-
if ($chunk === null) {
|
108 |
-
$ended = true;
|
109 |
-
}
|
110 |
-
return $chunk;
|
111 |
-
}, STREAM_FILTER_WRITE);
|
112 |
-
|
113 |
-
$this->assertEquals(0, $ended);
|
114 |
-
StreamFilter\remove($filter);
|
115 |
-
$this->assertEquals(1, $ended);
|
116 |
-
}
|
117 |
-
|
118 |
-
public function testAppendEndEventWillBeCalledOnClose()
|
119 |
-
{
|
120 |
-
$stream = $this->createStream();
|
121 |
-
|
122 |
-
$ended = false;
|
123 |
-
StreamFilter\append($stream, function ($chunk = null) use (&$ended) {
|
124 |
-
if ($chunk === null) {
|
125 |
-
$ended = true;
|
126 |
-
}
|
127 |
-
return $chunk;
|
128 |
-
}, STREAM_FILTER_WRITE);
|
129 |
-
|
130 |
-
$this->assertEquals(0, $ended);
|
131 |
-
fclose($stream);
|
132 |
-
$this->assertEquals(1, $ended);
|
133 |
-
}
|
134 |
-
|
135 |
-
public function testAppendWriteOnly()
|
136 |
-
{
|
137 |
-
$stream = $this->createStream();
|
138 |
-
|
139 |
-
$invoked = 0;
|
140 |
-
|
141 |
-
StreamFilter\append($stream, function ($chunk) use (&$invoked) {
|
142 |
-
++$invoked;
|
143 |
-
|
144 |
-
return $chunk;
|
145 |
-
}, STREAM_FILTER_WRITE);
|
146 |
-
|
147 |
-
fwrite($stream, 'a');
|
148 |
-
fwrite($stream, 'b');
|
149 |
-
fwrite($stream, 'c');
|
150 |
-
rewind($stream);
|
151 |
-
|
152 |
-
$this->assertEquals(3, $invoked);
|
153 |
-
$this->assertEquals('abc', stream_get_contents($stream));
|
154 |
-
|
155 |
-
fclose($stream);
|
156 |
-
}
|
157 |
-
|
158 |
-
public function testAppendReadOnly()
|
159 |
-
{
|
160 |
-
$stream = $this->createStream();
|
161 |
-
|
162 |
-
$invoked = 0;
|
163 |
-
|
164 |
-
StreamFilter\append($stream, function ($chunk) use (&$invoked) {
|
165 |
-
++$invoked;
|
166 |
-
|
167 |
-
return $chunk;
|
168 |
-
}, STREAM_FILTER_READ);
|
169 |
-
|
170 |
-
fwrite($stream, 'a');
|
171 |
-
fwrite($stream, 'b');
|
172 |
-
fwrite($stream, 'c');
|
173 |
-
rewind($stream);
|
174 |
-
|
175 |
-
$this->assertEquals(0, $invoked);
|
176 |
-
$this->assertEquals('abc', stream_get_contents($stream));
|
177 |
-
$this->assertEquals(1, $invoked);
|
178 |
-
|
179 |
-
fclose($stream);
|
180 |
-
}
|
181 |
-
|
182 |
-
public function testOrderCallingAppendAfterPrepend()
|
183 |
-
{
|
184 |
-
$stream = $this->createStream();
|
185 |
-
|
186 |
-
StreamFilter\append($stream, function ($chunk) {
|
187 |
-
return '[' . $chunk . ']';
|
188 |
-
}, STREAM_FILTER_WRITE);
|
189 |
-
|
190 |
-
StreamFilter\prepend($stream, function ($chunk) {
|
191 |
-
return '(' . $chunk . ')';
|
192 |
-
}, STREAM_FILTER_WRITE);
|
193 |
-
|
194 |
-
fwrite($stream, 'hello');
|
195 |
-
rewind($stream);
|
196 |
-
|
197 |
-
$this->assertEquals('[(hello)]', stream_get_contents($stream));
|
198 |
-
|
199 |
-
fclose($stream);
|
200 |
-
}
|
201 |
-
|
202 |
-
public function testRemoveFilter()
|
203 |
-
{
|
204 |
-
$stream = $this->createStream();
|
205 |
-
|
206 |
-
$first = StreamFilter\append($stream, function ($chunk) {
|
207 |
-
return $chunk . '?';
|
208 |
-
}, STREAM_FILTER_WRITE);
|
209 |
-
|
210 |
-
StreamFilter\append($stream, function ($chunk) {
|
211 |
-
return $chunk . '!';
|
212 |
-
}, STREAM_FILTER_WRITE);
|
213 |
-
|
214 |
-
StreamFilter\remove($first);
|
215 |
-
|
216 |
-
fwrite($stream, 'hello');
|
217 |
-
rewind($stream);
|
218 |
-
|
219 |
-
$this->assertEquals('hello!', stream_get_contents($stream));
|
220 |
-
|
221 |
-
fclose($stream);
|
222 |
-
}
|
223 |
-
|
224 |
-
public function testAppendFunDechunk()
|
225 |
-
{
|
226 |
-
if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (dechunk filter does not exist)');
|
227 |
-
|
228 |
-
$stream = $this->createStream();
|
229 |
-
|
230 |
-
StreamFilter\append($stream, StreamFilter\fun('dechunk'), STREAM_FILTER_WRITE);
|
231 |
-
|
232 |
-
fwrite($stream, "2\r\nhe\r\n");
|
233 |
-
fwrite($stream, "3\r\nllo\r\n");
|
234 |
-
fwrite($stream, "0\r\n\r\n");
|
235 |
-
rewind($stream);
|
236 |
-
|
237 |
-
$this->assertEquals('hello', stream_get_contents($stream));
|
238 |
-
|
239 |
-
fclose($stream);
|
240 |
-
}
|
241 |
-
|
242 |
-
public function testAppendThrows()
|
243 |
-
{
|
244 |
-
$this->createErrorHandler($errors);
|
245 |
-
|
246 |
-
$stream = $this->createStream();
|
247 |
-
$this->createErrorHandler($errors);
|
248 |
-
|
249 |
-
StreamFilter\append($stream, function ($chunk) {
|
250 |
-
throw new \DomainException($chunk);
|
251 |
-
});
|
252 |
-
|
253 |
-
fwrite($stream, 'test');
|
254 |
-
|
255 |
-
$this->removeErrorHandler();
|
256 |
-
$this->assertCount(1, $errors);
|
257 |
-
$this->assertContains('test', $errors[0]);
|
258 |
-
}
|
259 |
-
|
260 |
-
public function testAppendThrowsDuringEnd()
|
261 |
-
{
|
262 |
-
$stream = $this->createStream();
|
263 |
-
$this->createErrorHandler($errors);
|
264 |
-
|
265 |
-
StreamFilter\append($stream, function ($chunk = null) {
|
266 |
-
if ($chunk === null) {
|
267 |
-
throw new \DomainException('end');
|
268 |
-
}
|
269 |
-
return $chunk;
|
270 |
-
});
|
271 |
-
|
272 |
-
fclose($stream);
|
273 |
-
|
274 |
-
$this->removeErrorHandler();
|
275 |
-
|
276 |
-
// We can only assert we're not seeing an exception here…
|
277 |
-
// * php 5.3-5.6 sees one error here
|
278 |
-
// * php 7 does not see any error here
|
279 |
-
// * hhvm sees the same error twice
|
280 |
-
//
|
281 |
-
// If you're curious:
|
282 |
-
//
|
283 |
-
// var_dump($errors);
|
284 |
-
// $this->assertCount(1, $errors);
|
285 |
-
// $this->assertContains('end', $errors[0]);
|
286 |
-
}
|
287 |
-
|
288 |
-
public function testAppendThrowsShouldTriggerEnd()
|
289 |
-
{
|
290 |
-
$stream = $this->createStream();
|
291 |
-
$this->createErrorHandler($errors);
|
292 |
-
|
293 |
-
$ended = false;
|
294 |
-
StreamFilter\append($stream, function ($chunk = null) use (&$ended) {
|
295 |
-
if ($chunk === null) {
|
296 |
-
$ended = true;
|
297 |
-
return '';
|
298 |
-
}
|
299 |
-
throw new \DomainException($chunk);
|
300 |
-
});
|
301 |
-
|
302 |
-
$this->assertEquals(false, $ended);
|
303 |
-
fwrite($stream, 'test');
|
304 |
-
$this->assertEquals(true, $ended);
|
305 |
-
|
306 |
-
$this->removeErrorHandler();
|
307 |
-
$this->assertCount(1, $errors);
|
308 |
-
$this->assertContains('test', $errors[0]);
|
309 |
-
}
|
310 |
-
|
311 |
-
public function testAppendThrowsShouldTriggerEndButIgnoreExceptionDuringEnd()
|
312 |
-
{
|
313 |
-
//$this->markTestIncomplete();
|
314 |
-
$stream = $this->createStream();
|
315 |
-
$this->createErrorHandler($errors);
|
316 |
-
|
317 |
-
StreamFilter\append($stream, function ($chunk = null) {
|
318 |
-
if ($chunk === null) {
|
319 |
-
$chunk = 'end';
|
320 |
-
//return '';
|
321 |
-
}
|
322 |
-
throw new \DomainException($chunk);
|
323 |
-
});
|
324 |
-
|
325 |
-
fwrite($stream, 'test');
|
326 |
-
|
327 |
-
$this->removeErrorHandler();
|
328 |
-
$this->assertCount(1, $errors);
|
329 |
-
$this->assertContains('test', $errors[0]);
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* @expectedException RuntimeException
|
334 |
-
*/
|
335 |
-
public function testAppendInvalidStreamIsRuntimeError()
|
336 |
-
{
|
337 |
-
if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)');
|
338 |
-
StreamFilter\append(false, function () { });
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* @expectedException RuntimeException
|
343 |
-
*/
|
344 |
-
public function testPrependInvalidStreamIsRuntimeError()
|
345 |
-
{
|
346 |
-
if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)');
|
347 |
-
StreamFilter\prepend(false, function () { });
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* @expectedException RuntimeException
|
352 |
-
*/
|
353 |
-
public function testRemoveInvalidFilterIsRuntimeError()
|
354 |
-
{
|
355 |
-
if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid filters)');
|
356 |
-
StreamFilter\remove(false);
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* @expectedException InvalidArgumentException
|
361 |
-
*/
|
362 |
-
public function testInvalidCallbackIsInvalidArgument()
|
363 |
-
{
|
364 |
-
$stream = $this->createStream();
|
365 |
-
|
366 |
-
StreamFilter\append($stream, 'a-b-c');
|
367 |
-
}
|
368 |
-
|
369 |
-
private function createStream()
|
370 |
-
{
|
371 |
-
return fopen('php://memory', 'r+');
|
372 |
-
}
|
373 |
-
|
374 |
-
private function createErrorHandler(&$errors)
|
375 |
-
{
|
376 |
-
$errors = array();
|
377 |
-
set_error_handler(function ($_, $message) use (&$errors) {
|
378 |
-
$errors []= $message;
|
379 |
-
});
|
380 |
-
}
|
381 |
-
|
382 |
-
private function removeErrorHandler()
|
383 |
-
{
|
384 |
-
restore_error_handler();
|
385 |
-
}
|
386 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
use Clue\StreamFilter as Filter;
|
4 |
-
|
5 |
-
class FunTest extends PHPUnit_Framework_TestCase
|
6 |
-
{
|
7 |
-
public function testFunInRot13()
|
8 |
-
{
|
9 |
-
$rot = Filter\fun('string.rot13');
|
10 |
-
|
11 |
-
$this->assertEquals('grfg', $rot('test'));
|
12 |
-
$this->assertEquals('test', $rot($rot('test')));
|
13 |
-
$this->assertEquals(null, $rot());
|
14 |
-
}
|
15 |
-
|
16 |
-
public function testFunInQuotedPrintable()
|
17 |
-
{
|
18 |
-
$encode = Filter\fun('convert.quoted-printable-encode');
|
19 |
-
$decode = Filter\fun('convert.quoted-printable-decode');
|
20 |
-
|
21 |
-
$this->assertEquals('t=C3=A4st', $encode('täst'));
|
22 |
-
$this->assertEquals('täst', $decode($encode('täst')));
|
23 |
-
$this->assertEquals(null, $encode());
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @expectedException RuntimeException
|
28 |
-
*/
|
29 |
-
public function testFunWriteAfterCloseRot13()
|
30 |
-
{
|
31 |
-
$rot = Filter\fun('string.rot13');
|
32 |
-
|
33 |
-
$this->assertEquals(null, $rot());
|
34 |
-
$rot('test');
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @expectedException RuntimeException
|
39 |
-
*/
|
40 |
-
public function testFunInvalid()
|
41 |
-
{
|
42 |
-
Filter\fun('unknown');
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunZlibTest.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
use Clue\StreamFilter;
|
4 |
-
|
5 |
-
class BuiltInZlibTest extends PHPUnit_Framework_TestCase
|
6 |
-
{
|
7 |
-
public function testFunZlibDeflateHelloWorld()
|
8 |
-
{
|
9 |
-
$deflate = StreamFilter\fun('zlib.deflate');
|
10 |
-
|
11 |
-
$data = $deflate('hello') . $deflate(' ') . $deflate('world') . $deflate();
|
12 |
-
|
13 |
-
$this->assertEquals(gzdeflate('hello world'), $data);
|
14 |
-
}
|
15 |
-
|
16 |
-
public function testFunZlibDeflateEmpty()
|
17 |
-
{
|
18 |
-
if (PHP_VERSION >= 7) $this->markTestSkipped('Not supported on PHP7 (empty string does not invoke filter)');
|
19 |
-
|
20 |
-
$deflate = StreamFilter\fun('zlib.deflate');
|
21 |
-
|
22 |
-
//$data = gzdeflate('');
|
23 |
-
$data = $deflate();
|
24 |
-
|
25 |
-
$this->assertEquals("\x03\x00", $data);
|
26 |
-
}
|
27 |
-
|
28 |
-
public function testFunZlibDeflateBig()
|
29 |
-
{
|
30 |
-
$deflate = StreamFilter\fun('zlib.deflate');
|
31 |
-
|
32 |
-
$n = 1000;
|
33 |
-
$expected = str_repeat('hello', $n);
|
34 |
-
|
35 |
-
$bytes = '';
|
36 |
-
for ($i = 0; $i < $n; ++$i) {
|
37 |
-
$bytes .= $deflate('hello');
|
38 |
-
}
|
39 |
-
$bytes .= $deflate();
|
40 |
-
|
41 |
-
$this->assertEquals($expected, gzinflate($bytes));
|
42 |
-
}
|
43 |
-
|
44 |
-
public function testFunZlibInflateHelloWorld()
|
45 |
-
{
|
46 |
-
$inflate = StreamFilter\fun('zlib.inflate');
|
47 |
-
|
48 |
-
$data = $inflate(gzdeflate('hello world')) . $inflate();
|
49 |
-
|
50 |
-
$this->assertEquals('hello world', $data);
|
51 |
-
}
|
52 |
-
|
53 |
-
public function testFunZlibInflateEmpty()
|
54 |
-
{
|
55 |
-
$inflate = StreamFilter\fun('zlib.inflate');
|
56 |
-
|
57 |
-
$data = $inflate("\x03\x00") . $inflate();
|
58 |
-
|
59 |
-
$this->assertEquals('', $data);
|
60 |
-
}
|
61 |
-
|
62 |
-
public function testFunZlibInflateBig()
|
63 |
-
{
|
64 |
-
if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (final chunk will not be emitted)');
|
65 |
-
|
66 |
-
$inflate = StreamFilter\fun('zlib.inflate');
|
67 |
-
|
68 |
-
$expected = str_repeat('hello', 10);
|
69 |
-
$bytes = gzdeflate($expected);
|
70 |
-
|
71 |
-
$ret = '';
|
72 |
-
foreach (str_split($bytes, 2) as $chunk) {
|
73 |
-
$ret .= $inflate($chunk);
|
74 |
-
}
|
75 |
-
$ret .= $inflate();
|
76 |
-
|
77 |
-
$this->assertEquals($expected, $ret);
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/appveyor.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
build: false
|
2 |
-
platform:
|
3 |
-
- x86
|
4 |
-
- x64
|
5 |
-
|
6 |
-
clone_folder: c:\projects\php-http\multipart-stream-builder
|
7 |
-
|
8 |
-
cache:
|
9 |
-
- c:\tools\php -> appveyor.yml
|
10 |
-
|
11 |
-
init:
|
12 |
-
- SET PATH=c:\php;%PATH%
|
13 |
-
- SET COMPOSER_NO_INTERACTION=1
|
14 |
-
- SET PHP=1
|
15 |
-
|
16 |
-
|
17 |
-
install:
|
18 |
-
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
|
19 |
-
- cd c:\php
|
20 |
-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.0-nts-Win32-VC14-x86.zip
|
21 |
-
- IF %PHP%==1 7z x php-7.0.0-nts-Win32-VC14-x86.zip -y >nul
|
22 |
-
- IF %PHP%==1 del /Q *.zip
|
23 |
-
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
|
24 |
-
- IF %PHP%==1 copy /Y php.ini-development php.ini
|
25 |
-
- IF %PHP%==1 echo max_execution_time=1200 >> php.ini
|
26 |
-
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
|
27 |
-
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
28 |
-
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
|
29 |
-
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
|
30 |
-
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
|
31 |
-
- appveyor DownloadFile https://getcomposer.org/composer.phar
|
32 |
-
- cd c:\projects\php-http\multipart-stream-builder
|
33 |
-
- mkdir %APPDATA%\Composer
|
34 |
-
- composer update --prefer-dist --no-progress --ansi
|
35 |
-
|
36 |
-
test_script:
|
37 |
-
- cd c:\projects\php-http\multipart-stream-builder
|
38 |
-
- vendor\bin\phpunit.bat --verbose
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/CHANGELOG.md
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
# Change Log
|
2 |
-
All notable changes to this project will be documented in this file.
|
3 |
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
4 |
-
|
5 |
-
## [v3.2.0] - (2015-05-13)
|
6 |
-
### Added
|
7 |
-
- Specify Guzzle proxy via [#149](https://github.com/sendgrid/sendgrid-php/pull/149)
|
8 |
-
- Option to disable exception raising
|
9 |
-
|
10 |
-
## [v3.1.0] - (2015-04-27)
|
11 |
-
### Added
|
12 |
-
- Support for API keys
|
13 |
-
|
14 |
-
## [v3.0.0] - (2015-04-14)
|
15 |
-
### Fixed
|
16 |
-
- CC and BCC not working with SMTPAPI To
|
17 |
-
|
18 |
-
### Changed
|
19 |
-
- **Breaking:** A `\SendGrid\Exception` is now raised when response is not 200
|
20 |
-
- **Breaking:** `addTo` now uses the Web API parameter as opposed to the SMTPAPI Header. Substitutions will most likely break unless you update to use `addSmtpapiTo`
|
21 |
-
- The library now depends on Guzzle3
|
22 |
-
- Major refactoring
|
23 |
-
|
24 |
-
### Added
|
25 |
-
- **Breaking:** `send()` now returns an instance of `\SendGrid\Response`
|
26 |
-
- Numerous missing methods for new functionality
|
27 |
-
- `addSmtpapiTo` for using the SMTPAPI To
|
28 |
-
|
29 |
-
## [v2.2.1] - (2014-01-29)
|
30 |
-
### Fixed
|
31 |
-
- Fix turn_off_ssl_verification option via [#123](https://github.com/sendgrid/sendgrid-php/pull/123)
|
32 |
-
|
33 |
-
## [v2.2.0] - (2014-01-12)
|
34 |
-
### Changed
|
35 |
-
- Remove [Unirest](https://github.com/Mashape/unirest-php/) and replace with native cURL
|
36 |
-
- Add CHANGELOG.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/MIT.LICENSE
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
Copyright (c) 2013 SendGrid
|
2 |
-
|
3 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
4 |
-
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
5 |
-
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
6 |
-
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
7 |
-
|
8 |
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
9 |
-
the Software.
|
10 |
-
|
11 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
12 |
-
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
13 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
14 |
-
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
15 |
-
DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/README.md
DELETED
@@ -1,958 +0,0 @@
|
|
1 |
-
# SendGrid-PHP
|
2 |
-
|
3 |
-
This library allows you to quickly and easily send emails through SendGrid using PHP.
|
4 |
-
|
5 |
-
WARNING: This module was recently upgraded from [2.2.x](https://github.com/sendgrid/sendgrid-php/tree/v2.2.1) to 3.X. There were API breaking changes for various method names. See [usage](https://github.com/sendgrid/sendgrid-php#usage) for up to date method names.
|
6 |
-
|
7 |
-
## PLEASE READ THIS
|
8 |
-
|
9 |
-
**TLDR: If you upgrade and don't change your code appropriately, things *WILL* break.**
|
10 |
-
|
11 |
-
One of the most notable changes is how `addTo()` behaves. We are now using our Web API parameters instead of the X-SMTPAPI header. What this means is that if you call `addTo()` multiple times for an email, **ONE** email will be sent with each email address visible to everyone. To utilize the original behavior of having an individual personalized email sent to each recipient you must now use `addSmtpapiTo()`. **This will break substitutions if there is more than one To address added unless you update to use `addSmtpapiTo()`.**
|
12 |
-
|
13 |
-
Smtpapi addressing methods cannot be mixed with non Smtpapi addressing methods. Meaning you cannot currently use Cc and Bcc with `addSmtpapiTo()`.
|
14 |
-
|
15 |
-
The `send()` method now raises a `\SendGrid\Exception` by default if the response code is not 200 and returns an instance of `\SendGrid\Response`.
|
16 |
-
|
17 |
-
---
|
18 |
-
|
19 |
-
Important: This library requires PHP 5.3 or higher.
|
20 |
-
|
21 |
-
[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-php.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-php)
|
22 |
-
[![Latest Stable Version](https://poser.pugx.org/sendgrid/sendgrid/version.svg)](https://packagist.org/packages/sendgrid/sendgrid)
|
23 |
-
|
24 |
-
```php
|
25 |
-
$sendgrid = new SendGrid('username', 'password');
|
26 |
-
$email = new SendGrid\Email();
|
27 |
-
$email
|
28 |
-
->addTo('foo@bar.com')
|
29 |
-
->setFrom('me@bar.com')
|
30 |
-
->setSubject('Subject goes here')
|
31 |
-
->setText('Hello World!')
|
32 |
-
->setHtml('<strong>Hello World!</strong>')
|
33 |
-
;
|
34 |
-
|
35 |
-
$sendgrid->send($email);
|
36 |
-
|
37 |
-
// Or catch the error
|
38 |
-
|
39 |
-
try {
|
40 |
-
$sendgrid->send($email);
|
41 |
-
} catch(\SendGrid\Exception $e) {
|
42 |
-
echo $e->getCode();
|
43 |
-
foreach($e->getErrors() as $er) {
|
44 |
-
echo $er;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
```
|
48 |
-
|
49 |
-
## Installation
|
50 |
-
|
51 |
-
Add SendGrid to your `composer.json` file. If you are not using [Composer](http://getcomposer.org), you should be. It's an excellent way to manage dependencies in your PHP application.
|
52 |
-
|
53 |
-
```json
|
54 |
-
{
|
55 |
-
"require": {
|
56 |
-
"sendgrid/sendgrid": "~3.2"
|
57 |
-
}
|
58 |
-
}
|
59 |
-
```
|
60 |
-
|
61 |
-
Then at the top of your PHP script require the autoloader:
|
62 |
-
|
63 |
-
```bash
|
64 |
-
require 'vendor/autoload.php';
|
65 |
-
```
|
66 |
-
|
67 |
-
#### Alternative: Install from zip
|
68 |
-
|
69 |
-
If you are not using Composer, simply download and install the **[latest packaged release of the library as a zip](https://sendgrid-open-source.s3.amazonaws.com/sendgrid-php/sendgrid-php.zip)**.
|
70 |
-
|
71 |
-
[**⬇︎ Download Packaged Library ⬇︎**](https://sendgrid-open-source.s3.amazonaws.com/sendgrid-php/sendgrid-php.zip)
|
72 |
-
|
73 |
-
Then require the library from package:
|
74 |
-
|
75 |
-
```php
|
76 |
-
require("path/to/sendgrid-php/sendgrid-php.php");
|
77 |
-
```
|
78 |
-
|
79 |
-
Previous versions of the library can be found in the [version index](https://sendgrid-open-source.s3.amazonaws.com/index.html).
|
80 |
-
|
81 |
-
## Example App
|
82 |
-
|
83 |
-
There is a [sendgrid-php-example app](https://github.com/sendgrid/sendgrid-php-example) to help jumpstart your development.
|
84 |
-
|
85 |
-
## Usage
|
86 |
-
|
87 |
-
To begin using this library, initialize the SendGrid object with your SendGrid credentials OR a SendGrid [API Key](https://sendgrid.com/docs/Classroom/Send/api_keys.html). API Key is the preferred method. To configure API keys, visit https://app.sendgrid.com/settings/api_keys.
|
88 |
-
|
89 |
-
```php
|
90 |
-
$sendgrid = new SendGrid('username', 'password');
|
91 |
-
// OR
|
92 |
-
$sendgrid = new SendGrid('sendgrid api key');
|
93 |
-
```
|
94 |
-
|
95 |
-
Create a new SendGrid Email object and add your message details.
|
96 |
-
|
97 |
-
```php
|
98 |
-
$email = new SendGrid\Email();
|
99 |
-
$email
|
100 |
-
->addTo('foo@bar.com')
|
101 |
-
->addTo('bar@foo.com')
|
102 |
-
->setFrom('me@bar.com')
|
103 |
-
->setSubject('Subject goes here')
|
104 |
-
->setText('Hello World!')
|
105 |
-
->setHtml('<strong>Hello World!</strong>')
|
106 |
-
;
|
107 |
-
```
|
108 |
-
|
109 |
-
Send it.
|
110 |
-
|
111 |
-
```php
|
112 |
-
$sendgrid->send($email);
|
113 |
-
```
|
114 |
-
|
115 |
-
### Exceptions
|
116 |
-
|
117 |
-
A `SendGrid\Exception` is raised by default if the response is not 200 OK.
|
118 |
-
|
119 |
-
To disable exceptions, pass in the `raise_exceptions => false` option when creating a `SendGrid\Client`.
|
120 |
-
|
121 |
-
```php
|
122 |
-
$client = new SendGrid('SENDGRID_APIKEY', array('raise_exceptions' => false));
|
123 |
-
```
|
124 |
-
|
125 |
-
### Options
|
126 |
-
Options may be passed to the library when initializing the SendGrid object:
|
127 |
-
|
128 |
-
```php
|
129 |
-
$options = array(
|
130 |
-
'turn_off_ssl_verification' => false,
|
131 |
-
'protocol' => 'https',
|
132 |
-
'host' => 'api.sendgrid.com',
|
133 |
-
'endpoint' => '/api/mail.send.json',
|
134 |
-
'port' => null,
|
135 |
-
'url' => null,
|
136 |
-
'raise_exceptions' => false
|
137 |
-
);
|
138 |
-
$sendgrid = new SendGrid('username', 'password', $options);
|
139 |
-
// OR
|
140 |
-
$sendgrid = new SendGrid('sendgrid api key', $options);
|
141 |
-
```
|
142 |
-
|
143 |
-
#### Changing URL
|
144 |
-
You may change the URL sendgrid-php uses to send email by supplying various parameters to `options`, all parameters are optional:
|
145 |
-
|
146 |
-
```php
|
147 |
-
$sendgrid = new SendGrid(
|
148 |
-
'username',
|
149 |
-
'password',
|
150 |
-
array(
|
151 |
-
'protocol' => 'http',
|
152 |
-
'host' => 'sendgrid.org',
|
153 |
-
'endpoint' => '/send',
|
154 |
-
'port' => '80'
|
155 |
-
)
|
156 |
-
);
|
157 |
-
// OR
|
158 |
-
$sendgrid = new SendGrid(
|
159 |
-
'sendgrid_api_key',
|
160 |
-
array(
|
161 |
-
'protocol' => 'http',
|
162 |
-
'host' => 'sendgrid.org',
|
163 |
-
'endpoint' => '/send',
|
164 |
-
'port' => '80'
|
165 |
-
)
|
166 |
-
);
|
167 |
-
```
|
168 |
-
|
169 |
-
A full URL may also be provided:
|
170 |
-
|
171 |
-
```php
|
172 |
-
$sendgrid = new SendGrid(
|
173 |
-
'username',
|
174 |
-
'password',
|
175 |
-
array( 'url' => 'http://sendgrid.org:80/send')
|
176 |
-
);
|
177 |
-
// OR
|
178 |
-
$sendgrid = new SendGrid(
|
179 |
-
'sendgrid_api_key',
|
180 |
-
array( 'url' => 'http://sendgrid.org:80/send')
|
181 |
-
);
|
182 |
-
```
|
183 |
-
|
184 |
-
#### Ignoring SSL certificate verification
|
185 |
-
|
186 |
-
You can optionally ignore verification of SSL certificate when using the Web API.
|
187 |
-
|
188 |
-
```php
|
189 |
-
$sendgrid = new SendGrid(
|
190 |
-
'username',
|
191 |
-
'password',
|
192 |
-
array("turn_off_ssl_verification" => true)
|
193 |
-
);
|
194 |
-
// OR
|
195 |
-
$sendgrid = new SendGrid(
|
196 |
-
'sendgrid_api_key',
|
197 |
-
array("turn_off_ssl_verification" => true)
|
198 |
-
);
|
199 |
-
```
|
200 |
-
|
201 |
-
#### Response ####
|
202 |
-
|
203 |
-
An instance of `\SendGrid\Response` is returned from the `send()` method.
|
204 |
-
|
205 |
-
```php
|
206 |
-
$email = new SendGrid\Email();
|
207 |
-
$email
|
208 |
-
->addTo('foo@bar.com')
|
209 |
-
->setFrom('me@bar.com')
|
210 |
-
->setSubject('Subject goes here')
|
211 |
-
->setText('Hello World!');
|
212 |
-
$res = sendgrid->send($email);
|
213 |
-
|
214 |
-
var_dump($res);
|
215 |
-
|
216 |
-
// Output
|
217 |
-
object(SendGrid\Response)#31 (4) {
|
218 |
-
["code"]=>
|
219 |
-
int(200)
|
220 |
-
["headers"]=>
|
221 |
-
object(Guzzle\Http\Message\Header\HeaderCollection)#48 (1) {
|
222 |
-
["headers":protected]=>
|
223 |
-
array(6) {
|
224 |
-
...
|
225 |
-
["content-type"]=>
|
226 |
-
object(Guzzle\Http\Message\Header)#41 (3) {
|
227 |
-
["values":protected]=>
|
228 |
-
array(1) {
|
229 |
-
[0]=>
|
230 |
-
string(16) "application/json"
|
231 |
-
}
|
232 |
-
["header":protected]=>
|
233 |
-
string(12) "Content-Type"
|
234 |
-
["glue":protected]=>
|
235 |
-
string(1) ","
|
236 |
-
}
|
237 |
-
...
|
238 |
-
}
|
239 |
-
}
|
240 |
-
["raw_body"]=>
|
241 |
-
string(21) "{"message":"success"}"
|
242 |
-
["body"]=>
|
243 |
-
array(1) {
|
244 |
-
["message"]=>
|
245 |
-
string(7) "success"
|
246 |
-
}
|
247 |
-
}
|
248 |
-
```
|
249 |
-
|
250 |
-
#### getCode ####
|
251 |
-
|
252 |
-
Returns the status code of the response.
|
253 |
-
|
254 |
-
```
|
255 |
-
$res = $sendgrid->send($email);
|
256 |
-
echo $res->getCode()
|
257 |
-
```
|
258 |
-
|
259 |
-
#### getHeaders ####
|
260 |
-
|
261 |
-
Returns the headers of the response as a [Guzzle\Http\Message\Header\HeaderCollection object](https://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Guzzle.Http.Message.Header.HeaderCollection.html).
|
262 |
-
|
263 |
-
```
|
264 |
-
$res = $sendgrid->send($email);
|
265 |
-
$guzzle = $res->getHeaders();
|
266 |
-
echo var_dump($guzzle);
|
267 |
-
```
|
268 |
-
|
269 |
-
#### getRawBody ####
|
270 |
-
|
271 |
-
Returns the unparsed JSON response from SendGrid.
|
272 |
-
|
273 |
-
```
|
274 |
-
$res = $sendgrid->send($email);
|
275 |
-
echo $res->getRawBody()
|
276 |
-
```
|
277 |
-
|
278 |
-
#### getBody ####
|
279 |
-
|
280 |
-
Returns the parsed JSON from SendGrid.
|
281 |
-
|
282 |
-
```
|
283 |
-
$res = $sendgrid->send($email);
|
284 |
-
echo var_dump($res->getBody());
|
285 |
-
```
|
286 |
-
|
287 |
-
### Exception ###
|
288 |
-
|
289 |
-
A `\SendGrid\Exception` is raised if the response code is not 200. Catching it is optional but highly recommended.
|
290 |
-
|
291 |
-
```php
|
292 |
-
try {
|
293 |
-
$sendgrid->send($email);
|
294 |
-
} catch(\SendGrid\Exception $e) {
|
295 |
-
echo $e->getCode() . "\n";
|
296 |
-
foreach($e->getErrors() as $er) {
|
297 |
-
echo $er;
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
// Output
|
302 |
-
400
|
303 |
-
Permission denied, wrong credentials
|
304 |
-
```
|
305 |
-
|
306 |
-
### SMTPAPI ###
|
307 |
-
|
308 |
-
This library makes use of [sendgrid/smtpapi-php](https://github.com/sendgrid/smtpapi-php/) for all things related to the [X-SMTPAPI Header](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).
|
309 |
-
|
310 |
-
---
|
311 |
-
|
312 |
-
### Library Methods ###
|
313 |
-
|
314 |
-
#### addTo
|
315 |
-
|
316 |
-
You can add one or multiple TO addresses using `addTo` along with an optional TO name. Note: If using TO names, each address needs a name.
|
317 |
-
|
318 |
-
```php
|
319 |
-
$email = new SendGrid\Email();
|
320 |
-
$email
|
321 |
-
->addTo('foo@bar.com')
|
322 |
-
->addTo('another@another.com')
|
323 |
-
;
|
324 |
-
$sendgrid->send($email);
|
325 |
-
|
326 |
-
// With names
|
327 |
-
$email = new SendGrid\Email();
|
328 |
-
$email
|
329 |
-
->addTo('foo@bar.com', 'Frank Foo')
|
330 |
-
->addTo('another@another.com', 'Joe Bar')
|
331 |
-
;
|
332 |
-
$sendgrid->send($email);
|
333 |
-
|
334 |
-
// As an array
|
335 |
-
$email = new SendGrid\Email();
|
336 |
-
$email
|
337 |
-
->addTo(array('foo@bar.com', 'bar@example'), array('Frank Foo', 'Brian Bar'))
|
338 |
-
;
|
339 |
-
$sendgrid->send($email);
|
340 |
-
```
|
341 |
-
|
342 |
-
#### addSmtpapiTo
|
343 |
-
|
344 |
-
Add a TO address to the smtpapi header along with an optional name.
|
345 |
-
|
346 |
-
```php
|
347 |
-
$email = new SendGrid\Email();
|
348 |
-
$email
|
349 |
-
->addSmtpapiTo('foo@bar.com')
|
350 |
-
->addSmtpapiTo('another@another.com', 'Mike Bar')
|
351 |
-
;
|
352 |
-
$sendgrid->send($email);
|
353 |
-
```
|
354 |
-
|
355 |
-
#### setTos
|
356 |
-
|
357 |
-
If you prefer, you can add multiple TO addresses as an array using the `setTos` method. This will unset any previous `addTo`s you appended.
|
358 |
-
|
359 |
-
```php
|
360 |
-
$email = new SendGrid\Email();
|
361 |
-
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
|
362 |
-
$email->setTos($emails);
|
363 |
-
$sendgrid->send($email);
|
364 |
-
```
|
365 |
-
|
366 |
-
#### setSmtpapiTos
|
367 |
-
|
368 |
-
```php
|
369 |
-
$email = new SendGrid\Email();
|
370 |
-
$emails = array("foo@bar.com", "Brian Bar <bar@example.com>", "other@example.com");
|
371 |
-
$email->setSmtpapiTos($emails);
|
372 |
-
$sendgrid->send($email);
|
373 |
-
```
|
374 |
-
|
375 |
-
#### setFrom
|
376 |
-
|
377 |
-
```php
|
378 |
-
$email = new SendGrid\Email();
|
379 |
-
$email->setFrom('foo@bar.com');
|
380 |
-
$sendgrid->send($email);
|
381 |
-
```
|
382 |
-
|
383 |
-
#### setFromName
|
384 |
-
|
385 |
-
```php
|
386 |
-
$email = new SendGrid\Email();
|
387 |
-
$email
|
388 |
-
->setFrom('foo@bar.com')
|
389 |
-
->setFromName('Foo Bar')
|
390 |
-
;
|
391 |
-
$sendgrid->send($email);
|
392 |
-
```
|
393 |
-
|
394 |
-
#### setReplyTo
|
395 |
-
|
396 |
-
```php
|
397 |
-
$email = new SendGrid\Email();
|
398 |
-
$email
|
399 |
-
->addTo('foo@bar.com')
|
400 |
-
->setReplyTo('someone.else@example.com')
|
401 |
-
->setFromName('John Doe')
|
402 |
-
...
|
403 |
-
;
|
404 |
-
```
|
405 |
-
|
406 |
-
### Cc
|
407 |
-
|
408 |
-
#### addCc
|
409 |
-
|
410 |
-
```php
|
411 |
-
$email = new SendGrid\Email();
|
412 |
-
$email->addCc('foo@bar.com');
|
413 |
-
$sendgrid->send($email);
|
414 |
-
```
|
415 |
-
|
416 |
-
#### setCc
|
417 |
-
|
418 |
-
```php
|
419 |
-
$email = new SendGrid\Email();
|
420 |
-
$email->setCc('foo@bar.com');
|
421 |
-
$sendgrid->send($email);
|
422 |
-
```
|
423 |
-
|
424 |
-
#### setCcs
|
425 |
-
|
426 |
-
```php
|
427 |
-
$email = new SendGrid\Email();
|
428 |
-
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
|
429 |
-
$email->setCcs($emails);
|
430 |
-
$sendgrid->send($email);
|
431 |
-
```
|
432 |
-
|
433 |
-
#### removeCc
|
434 |
-
|
435 |
-
```php
|
436 |
-
$email->removeCc('foo@bar.com');
|
437 |
-
```
|
438 |
-
|
439 |
-
### Bcc
|
440 |
-
|
441 |
-
Use multiple `addSmtpapiTo`s as a superior alternative to `setBcc`.
|
442 |
-
|
443 |
-
```php
|
444 |
-
$email = new SendGrid\Email();
|
445 |
-
$email
|
446 |
-
->addSmtpapiTo('foo@bar.com')
|
447 |
-
->addSmtpapiTo('someotheraddress@bar.com')
|
448 |
-
->addSmtpapiTo('another@another.com')
|
449 |
-
...
|
450 |
-
;
|
451 |
-
```
|
452 |
-
|
453 |
-
But if you do still have a need for Bcc you can do the following:
|
454 |
-
|
455 |
-
#### addBcc
|
456 |
-
|
457 |
-
```php
|
458 |
-
$email = new SendGrid\Email();
|
459 |
-
$email->addTo('bar@example.com');
|
460 |
-
$email->addBcc('foo@bar.com');
|
461 |
-
$sendgrid->send($email);
|
462 |
-
```
|
463 |
-
|
464 |
-
#### setBcc
|
465 |
-
|
466 |
-
```php
|
467 |
-
$email = new SendGrid\Email();
|
468 |
-
$email->setBcc('foo@bar.com');
|
469 |
-
$sendgrid->send($email);
|
470 |
-
```
|
471 |
-
|
472 |
-
#### setBccs
|
473 |
-
|
474 |
-
```php
|
475 |
-
$email = new SendGrid\Email();
|
476 |
-
$emails = array("foo@bar.com", "another@another.com", "other@other.com");
|
477 |
-
$email->setBccs($emails);
|
478 |
-
$sendgrid->send($email);
|
479 |
-
```
|
480 |
-
|
481 |
-
#### removeBcc
|
482 |
-
|
483 |
-
```php
|
484 |
-
$email->removeBcc('foo@bar.com');
|
485 |
-
```
|
486 |
-
|
487 |
-
**Important Gotcha**: Using multiple `addSmtpapiTo`s is recommended over bcc whenever possible. Each user will receive their own personalized email with that setup, and only see their own email.
|
488 |
-
|
489 |
-
Standard `setBcc` will hide who the email is addressed to. If you use multiple `addSmtpapiTo`'s, each user will receive a personalized email showing *only* their email. This is more friendly and more personal.
|
490 |
-
|
491 |
-
#### setSubject
|
492 |
-
|
493 |
-
```php
|
494 |
-
$email = new SendGrid\Email();
|
495 |
-
$email->setSubject('This is a subject');
|
496 |
-
$sendgrid->send($email);
|
497 |
-
```
|
498 |
-
|
499 |
-
#### setText
|
500 |
-
|
501 |
-
```php
|
502 |
-
$email = new SendGrid\Email();
|
503 |
-
$email->setText('This is some text');
|
504 |
-
$sendgrid->send($email);
|
505 |
-
```
|
506 |
-
|
507 |
-
#### setHtml
|
508 |
-
|
509 |
-
```php
|
510 |
-
$email = new SendGrid\Email();
|
511 |
-
$email->setHtml('<h1>This is an html email</h1>');
|
512 |
-
$sendgrid->send($email);
|
513 |
-
```
|
514 |
-
|
515 |
-
#### setDate
|
516 |
-
|
517 |
-
```php
|
518 |
-
$email = new SendGrid\Email();
|
519 |
-
$email->setDate('Wed, 17 Dec 2014 19:21:16 +0000');
|
520 |
-
$sendgrid->send($email);
|
521 |
-
```
|
522 |
-
|
523 |
-
#### setSendAt
|
524 |
-
|
525 |
-
```php
|
526 |
-
$email = new SendGrid\Email();
|
527 |
-
$email->setSendAt(1409348513);
|
528 |
-
$sendgrid->send($email);
|
529 |
-
```
|
530 |
-
|
531 |
-
#### setSendEachAt
|
532 |
-
|
533 |
-
```php
|
534 |
-
$email = new SendGrid\Email();
|
535 |
-
$email->setSendEachAt(array(1409348513, 1409348514, 1409348515));
|
536 |
-
$sendgrid->send($email);
|
537 |
-
```
|
538 |
-
|
539 |
-
#### addSendEachAt
|
540 |
-
|
541 |
-
```php
|
542 |
-
$email = new SendGrid\Email();
|
543 |
-
$email
|
544 |
-
->addSendEachAt(1409348513)
|
545 |
-
->addSendEachAt(1409348514)
|
546 |
-
->addSendEachAt(1409348515)
|
547 |
-
;
|
548 |
-
$sendgrid->send($email);
|
549 |
-
```
|
550 |
-
|
551 |
-
### Categories ###
|
552 |
-
|
553 |
-
Categories are used to group email statistics provided by SendGrid.
|
554 |
-
|
555 |
-
To use a category, simply set the category name. Note: there is a maximum of 10 categories per email.
|
556 |
-
|
557 |
-
#### addCategory
|
558 |
-
|
559 |
-
```php
|
560 |
-
$email = new SendGrid\Email();
|
561 |
-
$email
|
562 |
-
->addTo('foo@bar.com')
|
563 |
-
...
|
564 |
-
->addCategory("Category 1")
|
565 |
-
->addCategory("Category 2")
|
566 |
-
;
|
567 |
-
```
|
568 |
-
|
569 |
-
#### setCategory
|
570 |
-
|
571 |
-
```php
|
572 |
-
$email = new SendGrid\Email();
|
573 |
-
$email
|
574 |
-
->addTo('foo@bar.com')
|
575 |
-
...
|
576 |
-
->setCategory("Category 1")
|
577 |
-
;
|
578 |
-
```
|
579 |
-
|
580 |
-
#### setCategories
|
581 |
-
|
582 |
-
```php
|
583 |
-
$email = new SendGrid\Email();
|
584 |
-
$categories = array("Category 1", "Category 2", "Category 3");
|
585 |
-
$email->setCategories($categories);
|
586 |
-
```
|
587 |
-
|
588 |
-
#### removeCategory
|
589 |
-
|
590 |
-
```php
|
591 |
-
$email = new SendGrid\Email();
|
592 |
-
$email
|
593 |
-
->addTo('foo@bar.com')
|
594 |
-
...
|
595 |
-
->removeCategory("Category 1")
|
596 |
-
;
|
597 |
-
```
|
598 |
-
|
599 |
-
### Attachments ###
|
600 |
-
|
601 |
-
Attachments are currently file based only, with future plans for an in memory implementation as well.
|
602 |
-
|
603 |
-
File attachments are limited to 7 MB per file.
|
604 |
-
|
605 |
-
#### addAttachment
|
606 |
-
|
607 |
-
```php
|
608 |
-
$email = new SendGrid\Email();
|
609 |
-
$email
|
610 |
-
->addTo('foo@bar.com')
|
611 |
-
...
|
612 |
-
->addAttachment("../path/to/file.txt")
|
613 |
-
;
|
614 |
-
```
|
615 |
-
|
616 |
-
#### setAttachment
|
617 |
-
|
618 |
-
```php
|
619 |
-
$email = new SendGrid\Email();
|
620 |
-
$email
|
621 |
-
->addTo('foo@bar.com')
|
622 |
-
...
|
623 |
-
->setAttachment("../path/to/file.txt")
|
624 |
-
;
|
625 |
-
```
|
626 |
-
|
627 |
-
#### setAttachments
|
628 |
-
|
629 |
-
```php
|
630 |
-
$email = new SendGrid\Email();
|
631 |
-
$attachments = array("../path/to/file1.txt", "../path/to/file2.txt");
|
632 |
-
$email
|
633 |
-
->addTo('foo@bar.com')
|
634 |
-
...
|
635 |
-
->setAttachments($attachments)
|
636 |
-
;
|
637 |
-
```
|
638 |
-
|
639 |
-
#### removeAttachment
|
640 |
-
|
641 |
-
```php
|
642 |
-
$email = new SendGrid\Email();
|
643 |
-
$email
|
644 |
-
->addTo('foo@bar.com')
|
645 |
-
...
|
646 |
-
->addAttachment("../path/to/file.txt")
|
647 |
-
->removeAttachment("../path/to/file.txt")
|
648 |
-
;
|
649 |
-
```
|
650 |
-
|
651 |
-
You can tag files for use as inline HTML content. It will mark the file for inline disposition using the specified "cid".
|
652 |
-
|
653 |
-
```php
|
654 |
-
$email = new SendGrid\Email();
|
655 |
-
$email
|
656 |
-
->addTo('foo@bar.com')
|
657 |
-
->setHtml('<div>Our logo:<img src="cid:file-cid"></div>')
|
658 |
-
->addAttachment("../path/to/file.png", "super_file.png", "file-cid")
|
659 |
-
;
|
660 |
-
```
|
661 |
-
|
662 |
-
### Substitutions ###
|
663 |
-
|
664 |
-
Substitutions can be used to customize multi-recipient emails, and tailor them for the user.
|
665 |
-
|
666 |
-
Unless you are only sending to one recipient, please make sure to use `addSmtpapiTo()`.
|
667 |
-
|
668 |
-
#### addSubstitution
|
669 |
-
|
670 |
-
```php
|
671 |
-
$email = new SendGrid\Email();
|
672 |
-
$email
|
673 |
-
->addSmtpapiTo('john@somewhere.com')
|
674 |
-
->addSmtpapiTo('harry@somewhere.com')
|
675 |
-
->addSmtpapiTo('Bob@somewhere.com')
|
676 |
-
...
|
677 |
-
->setHtml("Hey %name%, we've seen that you've been gone for a while")
|
678 |
-
->addSubstitution('%name%', array('John', 'Harry', 'Bob'))
|
679 |
-
;
|
680 |
-
```
|
681 |
-
|
682 |
-
Substitutions can also be used to customize multi-recipient subjects.
|
683 |
-
|
684 |
-
```php
|
685 |
-
$email = new SendGrid\Email();
|
686 |
-
$email
|
687 |
-
->addSmtpapiTo(array('john@somewhere.com', 'harry@somewhere.com', 'bob@somewhere.com'))
|
688 |
-
->setSubject('%subject%')
|
689 |
-
->addSubstitution(
|
690 |
-
'%subject%',
|
691 |
-
array('Subject to John', 'Subject to Harry', 'Subject to Bob')
|
692 |
-
)
|
693 |
-
...
|
694 |
-
;
|
695 |
-
```
|
696 |
-
|
697 |
-
#### setSubstitutions
|
698 |
-
|
699 |
-
```php
|
700 |
-
$email = new SendGrid\Email();
|
701 |
-
$email
|
702 |
-
->addSmtpapiTo(array('john@somewhere.com', 'harry@somewhere.com', 'bob@somewhere.com'))
|
703 |
-
->setSubject('%subject%')
|
704 |
-
->setSubstitutions(array(
|
705 |
-
'%name%' => array('John', 'Harry', 'Bob'),
|
706 |
-
'%subject%' => array('Subject to John', 'Subject to Harry', 'Subject to Bob')
|
707 |
-
))
|
708 |
-
...
|
709 |
-
;
|
710 |
-
```
|
711 |
-
|
712 |
-
### Sections ###
|
713 |
-
|
714 |
-
Sections can be used to further customize messages for the end users. A section is only useful in conjunction with a substitution value.
|
715 |
-
|
716 |
-
#### addSection
|
717 |
-
|
718 |
-
```php
|
719 |
-
$email = new SendGrid\Email();
|
720 |
-
$email
|
721 |
-
->addSmtpapiTo('john@somewhere.com')
|
722 |
-
->addSmtpapiTo("harry@somewhere.com")
|
723 |
-
->addSmtpapiTo("Bob@somewhere.com")
|
724 |
-
...
|
725 |
-
->setHtml("Hey %name%, you work at %place%")
|
726 |
-
->addSubstitution("%name%", array("John", "Harry", "Bob"))
|
727 |
-
->addSubstitution("%place%", array("%office%", "%office%", "%home%"))
|
728 |
-
->addSection("%office%", "an office")
|
729 |
-
->addSection("%home%", "your house")
|
730 |
-
;
|
731 |
-
```
|
732 |
-
|
733 |
-
#### setSections
|
734 |
-
|
735 |
-
```php
|
736 |
-
$email = new SendGrid\Email();
|
737 |
-
$email
|
738 |
-
->addSmtpapiTo('john@somewhere.com')
|
739 |
-
->addSmtpapiTo("harry@somewhere.com")
|
740 |
-
->addSmtpapiTo("Bob@somewhere.com")
|
741 |
-
...
|
742 |
-
->setHtml("Hey %name%, you work at %place%")
|
743 |
-
->addSubstitution("%name%", array("John", "Harry", "Bob"))
|
744 |
-
->addSubstitution("%place%", array("%office%", "%office%", "%home%"))
|
745 |
-
->setSections(array("%office%" => "an office", "%home%" => "your house"))
|
746 |
-
;
|
747 |
-
```
|
748 |
-
|
749 |
-
### Unique Arguments ###
|
750 |
-
|
751 |
-
[Unique Arguments](https://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html) are used for tracking purposes.
|
752 |
-
|
753 |
-
#### addUniqueArg / addUniqueArgument
|
754 |
-
|
755 |
-
```php
|
756 |
-
$email = new SendGrid\Email();
|
757 |
-
$email
|
758 |
-
->addTo('foo@bar.com')
|
759 |
-
...
|
760 |
-
->addUniqueArg("Customer", "Someone")
|
761 |
-
->addUniqueArg("location", "Somewhere")
|
762 |
-
;
|
763 |
-
```
|
764 |
-
|
765 |
-
#### setUniqueArgs / setUniqueArguments
|
766 |
-
|
767 |
-
```php
|
768 |
-
$email = new SendGrid\Email();
|
769 |
-
$email
|
770 |
-
->addTo('foo@bar.com')
|
771 |
-
...
|
772 |
-
->setUniqueArgs(array('cow' => 'chicken'))
|
773 |
-
;
|
774 |
-
```
|
775 |
-
|
776 |
-
### Filter Settings ###
|
777 |
-
|
778 |
-
[Filter Settings](https://sendgrid.com/docs/API_Reference/SMTP_API/apps.html) are used to enable and disable apps, and to pass parameters to those apps.
|
779 |
-
|
780 |
-
#### addFilter / addFilterSetting
|
781 |
-
|
782 |
-
```php
|
783 |
-
$email = new SendGrid\Email();
|
784 |
-
$email
|
785 |
-
->addTo('foo@bar.com')
|
786 |
-
...
|
787 |
-
addFilter("gravatar", "enable", 1)
|
788 |
-
->addFilter("footer", "enable", 1)
|
789 |
-
->addFilter("footer", "text/plain", "Here is a plain text footer")
|
790 |
-
->addFilter(
|
791 |
-
"footer",
|
792 |
-
"text/html",
|
793 |
-
"<p style='color:red;'>Here is an HTML footer</p>"
|
794 |
-
)
|
795 |
-
;
|
796 |
-
```
|
797 |
-
|
798 |
-
#### setFilters / setFilterSettings
|
799 |
-
|
800 |
-
```php
|
801 |
-
$email = new SendGrid\Email();
|
802 |
-
$email
|
803 |
-
->addTo('foo@bar.com')
|
804 |
-
...
|
805 |
-
setFilters(array("gravatar" => array("settings" => array("enable" => 1))))
|
806 |
-
;
|
807 |
-
```
|
808 |
-
|
809 |
-
### Templates ###
|
810 |
-
|
811 |
-
You can easily use SendGrid's [template engine](https://sendgrid.com/docs/User_Guide/Apps/template_engine.html) by applying filters.
|
812 |
-
|
813 |
-
#### setTemplateId
|
814 |
-
|
815 |
-
```php
|
816 |
-
$email = new SendGrid\Email();
|
817 |
-
$email
|
818 |
-
->addTo('someone@example.com')
|
819 |
-
->setFrom('support@example.com')
|
820 |
-
->setFromName('Support')
|
821 |
-
->setSubject('Subject goes here')
|
822 |
-
// set html or text to an empty space (see http://git.io/hCNy)
|
823 |
-
->setHtml(' ') // <-- triggers the html version of the template
|
824 |
-
// AND / OR
|
825 |
-
->setText(' ') // <-- triggers the plaintext version of the template
|
826 |
-
->setTemplateId($templateId);
|
827 |
-
```
|
828 |
-
|
829 |
-
This is simply a convenience method for:
|
830 |
-
|
831 |
-
```php
|
832 |
-
$email = new SendGrid\Email();
|
833 |
-
$email
|
834 |
-
->addFilter('templates', 'enabled', 1)
|
835 |
-
->addFilter('templates', 'template_id', $templateId)
|
836 |
-
;
|
837 |
-
```
|
838 |
-
|
839 |
-
### Advanced Suppression Manager ###
|
840 |
-
|
841 |
-
[ASM](https://sendgrid.com/docs/User_Guide/advanced_suppression_manager.html) is used to handle suppression groups.
|
842 |
-
|
843 |
-
#### setAsmGroupId ####
|
844 |
-
|
845 |
-
```php
|
846 |
-
$email = new SendGrid\Email();
|
847 |
-
$email->setAsmGroupId('my_group_id');
|
848 |
-
```
|
849 |
-
|
850 |
-
### Headers ###
|
851 |
-
|
852 |
-
You can add standard email message headers as necessary.
|
853 |
-
|
854 |
-
#### addHeader
|
855 |
-
|
856 |
-
```php
|
857 |
-
$email = new SendGrid\Email();
|
858 |
-
$email
|
859 |
-
->addTo('foo@bar.com')
|
860 |
-
...
|
861 |
-
->addHeader('X-Sent-Using', 'SendGrid-API')
|
862 |
-
->addHeader('X-Transport', 'web')
|
863 |
-
;
|
864 |
-
```
|
865 |
-
|
866 |
-
#### setHeaders
|
867 |
-
|
868 |
-
```php
|
869 |
-
$email = new SendGrid\Email();
|
870 |
-
$email
|
871 |
-
->addTo('foo@bar.com')
|
872 |
-
...
|
873 |
-
->setHeaders(array('X-Sent-Using' => 'SendGrid-API', 'X-Transport' => 'web'))
|
874 |
-
;
|
875 |
-
```
|
876 |
-
|
877 |
-
#### removeHeader
|
878 |
-
|
879 |
-
```php
|
880 |
-
$email = new SendGrid\Email();
|
881 |
-
$email
|
882 |
-
->addTo('foo@bar.com')
|
883 |
-
...
|
884 |
-
->addHeader('X-Sent-Using', 'SendGrid-API')
|
885 |
-
->addHeader('X-Transport', 'web')
|
886 |
-
;
|
887 |
-
$email->removeHeader('X-Transport');
|
888 |
-
```
|
889 |
-
|
890 |
-
### Sending to 1,000s of emails in one batch
|
891 |
-
|
892 |
-
Sometimes you might want to send 1,000s of emails in one request. You can do that. It is recommended you break each batch up in 1,000 increments. So if you need to send to 5,000 emails, then you'd break this into a loop of 1,000 emails at a time.
|
893 |
-
|
894 |
-
```php
|
895 |
-
$sendgrid = new SendGrid(SENDGRID_USERNAME, SENDGRID_PASSWORD);
|
896 |
-
// OR
|
897 |
-
$sendgrid = new SendGrid(SENDGRID_APIKEY);
|
898 |
-
$email = new SendGrid\Email();
|
899 |
-
|
900 |
-
$recipients = array(
|
901 |
-
"alpha@mailinator.com",
|
902 |
-
"beta@mailinator.com",
|
903 |
-
"zeta@mailinator.com"
|
904 |
-
);
|
905 |
-
$names = array("Alpha", "Beta", "Zeta");
|
906 |
-
|
907 |
-
$email
|
908 |
-
->setFrom("from@mailinator.com")
|
909 |
-
->setSubject('[sendgrid-php-batch-email]')
|
910 |
-
->setSmtpapiTos($recipients)
|
911 |
-
->addSubstitution("%name%", $names)
|
912 |
-
->setText("Hey %name%, we have an email for you")
|
913 |
-
->setHtml("<h1>Hey %name%, we have an email for you</h1>")
|
914 |
-
;
|
915 |
-
|
916 |
-
$result = $sendgrid->send($email);
|
917 |
-
```
|
918 |
-
|
919 |
-
## Contributing
|
920 |
-
|
921 |
-
1. Fork it
|
922 |
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
923 |
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
924 |
-
4. Push to the branch (`git push origin my-new-feature`)
|
925 |
-
5. Create new Pull Request
|
926 |
-
|
927 |
-
## Running Tests
|
928 |
-
|
929 |
-
The existing tests in the `test` directory can be run using [PHPUnit](https://github.com/sebastianbergmann/phpunit/) with the following command:
|
930 |
-
|
931 |
-
````bash
|
932 |
-
composer update --dev
|
933 |
-
cd test
|
934 |
-
../vendor/bin/phpunit
|
935 |
-
```
|
936 |
-
|
937 |
-
or if you already have PHPUnit installed globally.
|
938 |
-
|
939 |
-
```bash
|
940 |
-
cd test
|
941 |
-
phpunit
|
942 |
-
```
|
943 |
-
|
944 |
-
## Releasing
|
945 |
-
|
946 |
-
To release a new version of this library, update the version in all locations, tag the version, and then push the tag up. Packagist.org takes care of the rest.
|
947 |
-
|
948 |
-
#### Testing uploading to Amazon S3
|
949 |
-
|
950 |
-
If you want to test uploading the zipped file to Amazon S3 (SendGrid employees only), do the following.
|
951 |
-
|
952 |
-
```
|
953 |
-
export S3_SIGNATURE="secret_signature"
|
954 |
-
export S3_POLICY="secret_policy"
|
955 |
-
export S3_BUCKET="sendgrid-open-source"
|
956 |
-
export S3_ACCESS_KEY="secret_access_key"
|
957 |
-
./scripts/s3upload.sh
|
958 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid.php
DELETED
@@ -1,156 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class SendGrid
|
4 |
-
{
|
5 |
-
const VERSION = '3.2.0';
|
6 |
-
|
7 |
-
protected
|
8 |
-
$namespace = 'SendGrid',
|
9 |
-
$headers = array('Content-Type' => 'application/json'),
|
10 |
-
$client,
|
11 |
-
$options;
|
12 |
-
|
13 |
-
public
|
14 |
-
$apiUser,
|
15 |
-
$apiKey,
|
16 |
-
$url,
|
17 |
-
$endpoint,
|
18 |
-
$version = self::VERSION;
|
19 |
-
|
20 |
-
public function __construct($apiUserOrKey, $apiKeyOrOptions = null, $options = array())
|
21 |
-
{
|
22 |
-
// Check if given a username + password or api key
|
23 |
-
if (is_string($apiKeyOrOptions)) {
|
24 |
-
// Username and password
|
25 |
-
$this->apiUser = $apiUserOrKey;
|
26 |
-
$this->apiKey = $apiKeyOrOptions;
|
27 |
-
$this->options = $options;
|
28 |
-
} elseif (is_array($apiKeyOrOptions) || $apiKeyOrOptions === null) {
|
29 |
-
// API key
|
30 |
-
$this->apiKey = $apiUserOrKey;
|
31 |
-
$this->apiUser = null;
|
32 |
-
|
33 |
-
// With options
|
34 |
-
if (is_array($apiKeyOrOptions)) {
|
35 |
-
$this->options = $apiKeyOrOptions;
|
36 |
-
}
|
37 |
-
} else {
|
38 |
-
// Won't be thrown?
|
39 |
-
throw new InvalidArgumentException('Need a username + password or api key!');
|
40 |
-
}
|
41 |
-
|
42 |
-
$this->options['turn_off_ssl_verification'] = (isset($this->options['turn_off_ssl_verification']) && $this->options['turn_off_ssl_verification'] == true);
|
43 |
-
if (!isset($this->options['raise_exceptions'])) {
|
44 |
-
$this->options['raise_exceptions'] = true;
|
45 |
-
}
|
46 |
-
$protocol = isset($this->options['protocol']) ? $this->options['protocol'] : 'https';
|
47 |
-
$host = isset($this->options['host']) ? $this->options['host'] : 'api.sendgrid.com';
|
48 |
-
$port = isset($this->options['port']) ? $this->options['port'] : '';
|
49 |
-
|
50 |
-
$this->url = isset($this->options['url']) ? $this->options['url'] : $protocol . '://' . $host . ($port ? ':' . $port : '');
|
51 |
-
$this->endpoint = isset($this->options['endpoint']) ? $this->options['endpoint'] : '/api/mail.send.json';
|
52 |
-
|
53 |
-
$this->client = $this->prepareHttpClient();
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Prepares the HTTP client
|
58 |
-
*
|
59 |
-
* @return \Guzzle\Http\Client
|
60 |
-
*/
|
61 |
-
private function prepareHttpClient()
|
62 |
-
{
|
63 |
-
$guzzleOption = array(
|
64 |
-
'request.options' => array(
|
65 |
-
'verify' => !$this->options['turn_off_ssl_verification'],
|
66 |
-
'exceptions' => (isset($this->options['enable_guzzle_exceptions']) && $this->options['enable_guzzle_exceptions'] == true)
|
67 |
-
)
|
68 |
-
);
|
69 |
-
|
70 |
-
// Using api key
|
71 |
-
if ($this->apiUser === null) {
|
72 |
-
$guzzleOption['request.options']['headers'] = array('Authorization' => 'Bearer ' . $this->apiKey);
|
73 |
-
}
|
74 |
-
|
75 |
-
// Using http proxy
|
76 |
-
if (isset($this->options['proxy'])) {
|
77 |
-
$guzzleOption['request.options']['proxy'] = $this->options['proxy'];
|
78 |
-
}
|
79 |
-
|
80 |
-
$client = new \Guzzle\Http\Client($this->url, $guzzleOption);
|
81 |
-
$client->setUserAgent('sendgrid/' . $this->version . ';php');
|
82 |
-
|
83 |
-
return $client;
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @return array The protected options array
|
88 |
-
*/
|
89 |
-
public function getOptions()
|
90 |
-
{
|
91 |
-
return $this->options;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Makes a post request to SendGrid to send an email
|
96 |
-
*
|
97 |
-
* @param SendGrid\Email $email Email object built
|
98 |
-
*
|
99 |
-
* @throws SendGrid\Exception if the response code is not 200
|
100 |
-
* @return stdClass SendGrid response object
|
101 |
-
*/
|
102 |
-
public function send(SendGrid\Email $email)
|
103 |
-
{
|
104 |
-
$form = $email->toWebFormat();
|
105 |
-
|
106 |
-
// Using username password
|
107 |
-
if ($this->apiUser !== null) {
|
108 |
-
$form['api_user'] = $this->apiUser;
|
109 |
-
$form['api_key'] = $this->apiKey;
|
110 |
-
}
|
111 |
-
|
112 |
-
$response = $this->postRequest($this->endpoint, $form);
|
113 |
-
|
114 |
-
if ($response->code != 200 && $this->options['raise_exceptions']) {
|
115 |
-
throw new SendGrid\Exception($response->raw_body, $response->code);
|
116 |
-
}
|
117 |
-
|
118 |
-
return $response;
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Makes the actual HTTP request to SendGrid
|
123 |
-
*
|
124 |
-
* @param $endpoint string endpoint to post to
|
125 |
-
* @param $form array web ready version of SendGrid\Email
|
126 |
-
*
|
127 |
-
* @return SendGrid\Response
|
128 |
-
*/
|
129 |
-
public function postRequest($endpoint, $form)
|
130 |
-
{
|
131 |
-
$req = $this->client->post($endpoint, null, $form);
|
132 |
-
|
133 |
-
$res = $req->send();
|
134 |
-
|
135 |
-
$response = new SendGrid\Response($res->getStatusCode(), $res->getHeaders(), $res->getBody(true), $res->json());
|
136 |
-
|
137 |
-
return $response;
|
138 |
-
}
|
139 |
-
|
140 |
-
public static function register_autoloader()
|
141 |
-
{
|
142 |
-
spl_autoload_register(array('SendGrid', 'autoloader'));
|
143 |
-
}
|
144 |
-
|
145 |
-
public static function autoloader($class)
|
146 |
-
{
|
147 |
-
// Check that the class starts with 'SendGrid'
|
148 |
-
if ($class == 'SendGrid' || stripos($class, 'SendGrid\\') === 0) {
|
149 |
-
$file = str_replace('\\', '/', $class);
|
150 |
-
|
151 |
-
if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
|
152 |
-
require_once(dirname(__FILE__) . '/' . $file . '.php');
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Email.php
DELETED
@@ -1,637 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace SendGrid;
|
4 |
-
|
5 |
-
class Email
|
6 |
-
{
|
7 |
-
public
|
8 |
-
$to,
|
9 |
-
$toName,
|
10 |
-
$from,
|
11 |
-
$fromName,
|
12 |
-
$replyTo,
|
13 |
-
$cc,
|
14 |
-
$ccName,
|
15 |
-
$bcc,
|
16 |
-
$bccName,
|
17 |
-
$subject,
|
18 |
-
$text,
|
19 |
-
$html,
|
20 |
-
$date,
|
21 |
-
$content,
|
22 |
-
$headers,
|
23 |
-
$smtpapi,
|
24 |
-
$attachments;
|
25 |
-
|
26 |
-
public function __construct() {
|
27 |
-
|
28 |
-
$this->fromName = false;
|
29 |
-
$this->replyTo = false;
|
30 |
-
$this->smtpapi = new \Smtpapi\Header();
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* _removeFromList
|
35 |
-
* Given a list of key/value pairs, removes the associated keys
|
36 |
-
* where a value matches the given string ($item)
|
37 |
-
*
|
38 |
-
* @param Array $list - the list of key/value pairs
|
39 |
-
* @param String $item - the value to be removed
|
40 |
-
*/
|
41 |
-
private function _removeFromList( &$list, $item, $key_field = null ) {
|
42 |
-
foreach ( $list as $key => $val ) {
|
43 |
-
if ( $key_field ) {
|
44 |
-
if ( $val[ $key_field ] == $item ) {
|
45 |
-
unset( $list[ $key ] );
|
46 |
-
}
|
47 |
-
} else {
|
48 |
-
if ( $val == $item ) {
|
49 |
-
unset( $list[ $key ] );
|
50 |
-
}
|
51 |
-
}
|
52 |
-
}
|
53 |
-
// repack the indices
|
54 |
-
$list = array_values( $list );
|
55 |
-
}
|
56 |
-
|
57 |
-
public function addTo( $email, $name = null ) {
|
58 |
-
if ( $this->to == null ) {
|
59 |
-
$this->to = array();
|
60 |
-
}
|
61 |
-
|
62 |
-
if ( is_array( $email ) ) {
|
63 |
-
foreach ( $email as $e ) {
|
64 |
-
$this->to[] = $e;
|
65 |
-
}
|
66 |
-
} else {
|
67 |
-
$this->to[] = $email;
|
68 |
-
}
|
69 |
-
|
70 |
-
if ( is_array( $name ) ) {
|
71 |
-
foreach ( $name as $n ) {
|
72 |
-
$this->addToName( $n );
|
73 |
-
}
|
74 |
-
} elseif ( $name ) {
|
75 |
-
$this->addToName( $name );
|
76 |
-
}
|
77 |
-
|
78 |
-
return $this;
|
79 |
-
}
|
80 |
-
|
81 |
-
public function addSmtpapiTo( $email, $name = null ) {
|
82 |
-
$this->smtpapi->addTo( $email, $name );
|
83 |
-
|
84 |
-
return $this;
|
85 |
-
}
|
86 |
-
|
87 |
-
public function setTos( array $emails ) {
|
88 |
-
$this->to = $emails;
|
89 |
-
|
90 |
-
return $this;
|
91 |
-
}
|
92 |
-
|
93 |
-
public function setSmtpapiTos( array $emails ) {
|
94 |
-
$this->smtpapi->setTos( $emails );
|
95 |
-
|
96 |
-
return $this;
|
97 |
-
}
|
98 |
-
|
99 |
-
public function addToName( $name ) {
|
100 |
-
if ( $this->toName == null ) {
|
101 |
-
$this->toName = array();
|
102 |
-
}
|
103 |
-
|
104 |
-
$this->toName[] = $name;
|
105 |
-
|
106 |
-
return $this;
|
107 |
-
}
|
108 |
-
|
109 |
-
public function getToNames() {
|
110 |
-
|
111 |
-
return $this->toName;
|
112 |
-
}
|
113 |
-
|
114 |
-
public function setFrom( $email ) {
|
115 |
-
$this->from = $email;
|
116 |
-
|
117 |
-
return $this;
|
118 |
-
}
|
119 |
-
|
120 |
-
public function getFrom( $as_array = false ) {
|
121 |
-
if ( $as_array && ($name = $this->getFromName()) ) {
|
122 |
-
return array( "$this->from" => $name );
|
123 |
-
} else {
|
124 |
-
return $this->from;
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
public function setFromName( $name ) {
|
129 |
-
$this->fromName = $name;
|
130 |
-
|
131 |
-
return $this;
|
132 |
-
}
|
133 |
-
|
134 |
-
public function getFromName() {
|
135 |
-
|
136 |
-
return $this->fromName;
|
137 |
-
}
|
138 |
-
|
139 |
-
public function setReplyTo( $email ) {
|
140 |
-
$this->replyTo = $email;
|
141 |
-
|
142 |
-
return $this;
|
143 |
-
}
|
144 |
-
|
145 |
-
public function getReplyTo() {
|
146 |
-
|
147 |
-
return $this->replyTo;
|
148 |
-
}
|
149 |
-
|
150 |
-
public function setCc( $email ) {
|
151 |
-
$this->cc = array( $email );
|
152 |
-
|
153 |
-
return $this;
|
154 |
-
}
|
155 |
-
|
156 |
-
public function setCcs( array $email_list ) {
|
157 |
-
$this->cc = $email_list;
|
158 |
-
|
159 |
-
return $this;
|
160 |
-
}
|
161 |
-
|
162 |
-
public function addCc( $email, $name = null ) {
|
163 |
-
if ( $this->cc == null ) {
|
164 |
-
$this->cc = array();
|
165 |
-
}
|
166 |
-
|
167 |
-
if ( is_array( $email ) ) {
|
168 |
-
foreach ( $email as $e ) {
|
169 |
-
$this->cc[] = $e;
|
170 |
-
}
|
171 |
-
} else {
|
172 |
-
$this->cc[] = $email;
|
173 |
-
}
|
174 |
-
|
175 |
-
if ( is_array( $name ) ) {
|
176 |
-
foreach ( $name as $n ) {
|
177 |
-
$this->addCcName( $n );
|
178 |
-
}
|
179 |
-
} elseif ( $name ) {
|
180 |
-
$this->addCcName( $name );
|
181 |
-
}
|
182 |
-
|
183 |
-
return $this;
|
184 |
-
}
|
185 |
-
|
186 |
-
public function addCcName( $name ) {
|
187 |
-
if ( $this->ccName == null ) {
|
188 |
-
$this->ccName = array();
|
189 |
-
}
|
190 |
-
|
191 |
-
$this->ccName[] = $name;
|
192 |
-
|
193 |
-
return $this;
|
194 |
-
}
|
195 |
-
|
196 |
-
public function removeCc( $email ) {
|
197 |
-
$this->_removeFromList( $this->cc, $email );
|
198 |
-
|
199 |
-
return $this;
|
200 |
-
}
|
201 |
-
|
202 |
-
public function getCcs() {
|
203 |
-
|
204 |
-
return $this->cc;
|
205 |
-
}
|
206 |
-
|
207 |
-
public function getCcNames() {
|
208 |
-
|
209 |
-
return $this->ccName;
|
210 |
-
}
|
211 |
-
|
212 |
-
public function setBcc( $email ) {
|
213 |
-
$this->bcc = array( $email );
|
214 |
-
|
215 |
-
return $this;
|
216 |
-
}
|
217 |
-
|
218 |
-
public function setBccs( $email_list ) {
|
219 |
-
$this->bcc = $email_list;
|
220 |
-
|
221 |
-
return $this;
|
222 |
-
}
|
223 |
-
|
224 |
-
public function addBcc( $email, $name = null ) {
|
225 |
-
if ( $this->bcc == null ) {
|
226 |
-
$this->bcc = array();
|
227 |
-
}
|
228 |
-
|
229 |
-
if ( is_array( $email ) ) {
|
230 |
-
foreach ( $email as $e ) {
|
231 |
-
$this->bcc[] = $e;
|
232 |
-
}
|
233 |
-
} else {
|
234 |
-
$this->bcc[] = $email;
|
235 |
-
}
|
236 |
-
|
237 |
-
if ( is_array( $name ) ) {
|
238 |
-
foreach ( $name as $n ) {
|
239 |
-
$this->addBccName( $n );
|
240 |
-
}
|
241 |
-
} elseif ( $name ) {
|
242 |
-
$this->addBccName( $name );
|
243 |
-
}
|
244 |
-
|
245 |
-
return $this;
|
246 |
-
}
|
247 |
-
|
248 |
-
public function addBccName( $name ) {
|
249 |
-
if ( $this->bccName == null ) {
|
250 |
-
$this->bccName = array();
|
251 |
-
}
|
252 |
-
|
253 |
-
$this->bccName[] = $name;
|
254 |
-
|
255 |
-
return $this;
|
256 |
-
}
|
257 |
-
|
258 |
-
public function getBccNames() {
|
259 |
-
|
260 |
-
return $this->bccName;
|
261 |
-
}
|
262 |
-
|
263 |
-
public function removeBcc( $email ) {
|
264 |
-
$this->_removeFromList( $this->bcc, $email );
|
265 |
-
|
266 |
-
return $this;
|
267 |
-
}
|
268 |
-
|
269 |
-
public function getBccs() {
|
270 |
-
|
271 |
-
return $this->bcc;
|
272 |
-
}
|
273 |
-
|
274 |
-
public function setSubject( $subject ) {
|
275 |
-
$this->subject = $subject;
|
276 |
-
|
277 |
-
return $this;
|
278 |
-
}
|
279 |
-
|
280 |
-
public function getSubject() {
|
281 |
-
|
282 |
-
return $this->subject;
|
283 |
-
}
|
284 |
-
|
285 |
-
public function setDate( $date ) {
|
286 |
-
$this->date = $date;
|
287 |
-
|
288 |
-
return $this;
|
289 |
-
}
|
290 |
-
|
291 |
-
public function getDate() {
|
292 |
-
|
293 |
-
return $this->date;
|
294 |
-
}
|
295 |
-
|
296 |
-
public function setText( $text ) {
|
297 |
-
$this->text = $text;
|
298 |
-
|
299 |
-
return $this;
|
300 |
-
}
|
301 |
-
|
302 |
-
public function getText() {
|
303 |
-
|
304 |
-
return $this->text;
|
305 |
-
}
|
306 |
-
|
307 |
-
public function setHtml( $html ) {
|
308 |
-
$this->html = $html;
|
309 |
-
|
310 |
-
return $this;
|
311 |
-
}
|
312 |
-
|
313 |
-
public function getHtml() {
|
314 |
-
|
315 |
-
return $this->html;
|
316 |
-
}
|
317 |
-
|
318 |
-
public function setSendAt( $timestamp ) {
|
319 |
-
$this->smtpapi->setSendAt( $timestamp );
|
320 |
-
|
321 |
-
return $this;
|
322 |
-
}
|
323 |
-
|
324 |
-
public function setSendEachAt( array $timestamps ) {
|
325 |
-
$this->smtpapi->setSendEachAt( $timestamps );
|
326 |
-
|
327 |
-
return $this;
|
328 |
-
}
|
329 |
-
|
330 |
-
public function addSendEachAt( $timestamp ) {
|
331 |
-
$this->smtpapi->addSendEachAt( $timestamp );
|
332 |
-
|
333 |
-
return $this;
|
334 |
-
}
|
335 |
-
|
336 |
-
/**
|
337 |
-
* Convenience method to add template
|
338 |
-
*
|
339 |
-
* @param string The id of the template
|
340 |
-
*
|
341 |
-
* @return $this
|
342 |
-
*/
|
343 |
-
public function setTemplateId( $templateId ) {
|
344 |
-
$this->addFilter( 'templates', 'enabled', 1 );
|
345 |
-
$this->addFilter( 'templates', 'template_id', $templateId );
|
346 |
-
|
347 |
-
return $this;
|
348 |
-
}
|
349 |
-
|
350 |
-
/** Convenience method to set asm group id
|
351 |
-
*
|
352 |
-
* @param string the group id
|
353 |
-
*
|
354 |
-
* @return $this
|
355 |
-
*/
|
356 |
-
public function setAsmGroupId( $groupId ) {
|
357 |
-
$this->smtpapi->setASMGroupID( $groupId );
|
358 |
-
|
359 |
-
return $this;
|
360 |
-
}
|
361 |
-
|
362 |
-
public function setAttachments( array $files ) {
|
363 |
-
$this->attachments = array();
|
364 |
-
|
365 |
-
foreach ( $files as $filename => $file ) {
|
366 |
-
if ( is_string( $filename ) ) {
|
367 |
-
$this->addAttachment( $file, $filename );
|
368 |
-
} else {
|
369 |
-
$this->addAttachment( $file );
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
return $this;
|
374 |
-
}
|
375 |
-
|
376 |
-
public function setAttachment( $file, $custom_filename = null, $cid = null ) {
|
377 |
-
$this->attachments = array( $this->getAttachmentInfo( $file, $custom_filename, $cid ) );
|
378 |
-
|
379 |
-
return $this;
|
380 |
-
}
|
381 |
-
|
382 |
-
public function addAttachment( $file, $custom_filename = null, $cid = null ) {
|
383 |
-
$this->attachments[] = $this->getAttachmentInfo( $file, $custom_filename, $cid );
|
384 |
-
|
385 |
-
return $this;
|
386 |
-
}
|
387 |
-
|
388 |
-
public function getAttachments() {
|
389 |
-
|
390 |
-
return $this->attachments;
|
391 |
-
}
|
392 |
-
|
393 |
-
public function removeAttachment( $file ) {
|
394 |
-
$this->_removeFromList( $this->attachments, $file, 'file' );
|
395 |
-
|
396 |
-
return $this;
|
397 |
-
}
|
398 |
-
|
399 |
-
private function getAttachmentInfo( $file, $custom_filename = null, $cid = null ) {
|
400 |
-
$info = pathinfo( $file );
|
401 |
-
$info['file'] = $file;
|
402 |
-
if ( ! is_null( $custom_filename ) ) {
|
403 |
-
$info['custom_filename'] = $custom_filename;
|
404 |
-
}
|
405 |
-
if ( $cid !== null ) {
|
406 |
-
$info['cid'] = $cid;
|
407 |
-
}
|
408 |
-
|
409 |
-
return $info;
|
410 |
-
}
|
411 |
-
|
412 |
-
public function setCategories( $categories ) {
|
413 |
-
$this->smtpapi->setCategories( $categories );
|
414 |
-
|
415 |
-
return $this;
|
416 |
-
}
|
417 |
-
|
418 |
-
public function setCategory( $category ) {
|
419 |
-
$this->smtpapi->setCategory( $category );
|
420 |
-
|
421 |
-
return $this;
|
422 |
-
}
|
423 |
-
|
424 |
-
public function addCategory( $category ) {
|
425 |
-
$this->smtpapi->addCategory( $category );
|
426 |
-
|
427 |
-
return $this;
|
428 |
-
}
|
429 |
-
|
430 |
-
public function removeCategory( $category ) {
|
431 |
-
$this->smtpapi->removeCategory( $category );
|
432 |
-
|
433 |
-
return $this;
|
434 |
-
}
|
435 |
-
|
436 |
-
public function setSubstitutions( $key_value_pairs ) {
|
437 |
-
$this->smtpapi->setSubstitutions( $key_value_pairs );
|
438 |
-
|
439 |
-
return $this;
|
440 |
-
}
|
441 |
-
|
442 |
-
public function addSubstitution( $from_value, array $to_values ) {
|
443 |
-
$this->smtpapi->addSubstitution( $from_value, $to_values );
|
444 |
-
|
445 |
-
return $this;
|
446 |
-
}
|
447 |
-
|
448 |
-
public function setSections( array $key_value_pairs ) {
|
449 |
-
$this->smtpapi->setSections( $key_value_pairs );
|
450 |
-
|
451 |
-
return $this;
|
452 |
-
}
|
453 |
-
|
454 |
-
public function addSection( $from_value, $to_value ) {
|
455 |
-
$this->smtpapi->addSection( $from_value, $to_value );
|
456 |
-
|
457 |
-
return $this;
|
458 |
-
}
|
459 |
-
|
460 |
-
public function setUniqueArgs( array $key_value_pairs ) {
|
461 |
-
$this->smtpapi->setUniqueArgs( $key_value_pairs );
|
462 |
-
|
463 |
-
return $this;
|
464 |
-
}
|
465 |
-
|
466 |
-
// synonym method
|
467 |
-
public function setUniqueArguments( array $key_value_pairs ) {
|
468 |
-
$this->smtpapi->setUniqueArgs( $key_value_pairs );
|
469 |
-
|
470 |
-
return $this;
|
471 |
-
}
|
472 |
-
|
473 |
-
public function addUniqueArg( $key, $value ) {
|
474 |
-
$this->smtpapi->addUniqueArg( $key, $value );
|
475 |
-
|
476 |
-
return $this;
|
477 |
-
}
|
478 |
-
|
479 |
-
// synonym method
|
480 |
-
public function addUniqueArgument( $key, $value ) {
|
481 |
-
$this->smtpapi->addUniqueArg( $key, $value );
|
482 |
-
|
483 |
-
return $this;
|
484 |
-
}
|
485 |
-
|
486 |
-
public function setFilters( $filter_settings ) {
|
487 |
-
$this->smtpapi->setFilters( $filter_settings );
|
488 |
-
|
489 |
-
return $this;
|
490 |
-
}
|
491 |
-
|
492 |
-
// synonym method
|
493 |
-
public function setFilterSettings( $filter_settings ) {
|
494 |
-
$this->smtpapi->setFilters( $filter_settings );
|
495 |
-
|
496 |
-
return $this;
|
497 |
-
}
|
498 |
-
|
499 |
-
public function addFilter( $filter_name, $parameter_name, $parameter_value ) {
|
500 |
-
$this->smtpapi->addFilter( $filter_name, $parameter_name, $parameter_value );
|
501 |
-
|
502 |
-
return $this;
|
503 |
-
}
|
504 |
-
|
505 |
-
// synonym method
|
506 |
-
public function addFilterSetting( $filter_name, $parameter_name, $parameter_value ) {
|
507 |
-
$this->smtpapi->addFilter( $filter_name, $parameter_name, $parameter_value );
|
508 |
-
|
509 |
-
return $this;
|
510 |
-
}
|
511 |
-
|
512 |
-
public function getHeaders() {
|
513 |
-
|
514 |
-
return $this->headers;
|
515 |
-
}
|
516 |
-
|
517 |
-
public function getHeadersJson() {
|
518 |
-
|
519 |
-
if ( count( $this->getHeaders() ) <= 0 ) {
|
520 |
-
return '{}';
|
521 |
-
}
|
522 |
-
|
523 |
-
return json_encode( $this->getHeaders(), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP );
|
524 |
-
}
|
525 |
-
|
526 |
-
public function setHeaders( $key_value_pairs ) {
|
527 |
-
$this->headers = $key_value_pairs;
|
528 |
-
|
529 |
-
return $this;
|
530 |
-
}
|
531 |
-
|
532 |
-
public function addHeader( $key, $value ) {
|
533 |
-
$this->headers[ $key ] = $value;
|
534 |
-
|
535 |
-
return $this;
|
536 |
-
}
|
537 |
-
|
538 |
-
public function removeHeader( $key ) {
|
539 |
-
unset( $this->headers[ $key ] );
|
540 |
-
|
541 |
-
return $this;
|
542 |
-
}
|
543 |
-
|
544 |
-
public function getSmtpapi() {
|
545 |
-
|
546 |
-
return $this->smtpapi;
|
547 |
-
}
|
548 |
-
|
549 |
-
public function toWebFormat() {
|
550 |
-
|
551 |
-
$web = array(
|
552 |
-
'to' => $this->to,
|
553 |
-
'from' => $this->getFrom(),
|
554 |
-
'x-smtpapi' => $this->smtpapi->jsonString(),
|
555 |
-
'subject' => $this->getSubject(),
|
556 |
-
'text' => $this->getText(),
|
557 |
-
'html' => $this->getHtml(),
|
558 |
-
'headers' => $this->getHeadersJson(),
|
559 |
-
);
|
560 |
-
|
561 |
-
if ( $this->getToNames() ) {
|
562 |
-
$web['toname'] = $this->getToNames();
|
563 |
-
}
|
564 |
-
if ( $this->getCcs() ) {
|
565 |
-
$web['cc'] = $this->getCcs();
|
566 |
-
}
|
567 |
-
if ( $this->getCcNames() ) {
|
568 |
-
$web['ccname'] = $this->getCcNames();
|
569 |
-
}
|
570 |
-
if ( $this->getBccs() ) {
|
571 |
-
$web['bcc'] = $this->getBccs();
|
572 |
-
}
|
573 |
-
if ( $this->getBccNames() ) {
|
574 |
-
$web['bccname'] = $this->getBccNames();
|
575 |
-
}
|
576 |
-
if ( $this->getFromName() ) {
|
577 |
-
$web['fromname'] = $this->getFromName();
|
578 |
-
}
|
579 |
-
if ( $this->getReplyTo() ) {
|
580 |
-
$web['replyto'] = $this->getReplyTo();
|
581 |
-
}
|
582 |
-
if ( $this->getDate() ) {
|
583 |
-
$web['date'] = $this->getDate();
|
584 |
-
}
|
585 |
-
if ( $this->smtpapi->to && (count( $this->smtpapi->to ) > 0) ) {
|
586 |
-
$web['to'] = '';
|
587 |
-
}
|
588 |
-
|
589 |
-
$web = $this->updateMissingTo( $web );
|
590 |
-
|
591 |
-
if ( $this->getAttachments() ) {
|
592 |
-
foreach ( $this->getAttachments() as $f ) {
|
593 |
-
$file = $f['file'];
|
594 |
-
$extension = null;
|
595 |
-
if ( array_key_exists( 'extension', $f ) ) {
|
596 |
-
$extension = $f['extension'];
|
597 |
-
};
|
598 |
-
$filename = $f['filename'];
|
599 |
-
$full_filename = $filename;
|
600 |
-
|
601 |
-
if ( isset( $extension ) ) {
|
602 |
-
$full_filename = $filename . '.' . $extension;
|
603 |
-
}
|
604 |
-
if ( array_key_exists( 'custom_filename', $f ) ) {
|
605 |
-
$full_filename = $f['custom_filename'];
|
606 |
-
}
|
607 |
-
|
608 |
-
if ( array_key_exists( 'cid', $f ) ) {
|
609 |
-
$web[ 'content[' . $full_filename . ']' ] = $f['cid'];
|
610 |
-
}
|
611 |
-
|
612 |
-
$contents = '@' . $file;
|
613 |
-
|
614 |
-
// Guzzle handles this for us.
|
615 |
-
// http://guzzle3.readthedocs.org/en/latest/http-client/request.html#post-requests
|
616 |
-
// if (class_exists('CurlFile', false)) { // php >= 5.5
|
617 |
-
// $contents = new \CurlFile($file, $extension, $filename);
|
618 |
-
// }
|
619 |
-
$web[ 'files[' . $full_filename . ']' ] = $contents;
|
620 |
-
};
|
621 |
-
}
|
622 |
-
|
623 |
-
return $web;
|
624 |
-
}
|
625 |
-
|
626 |
-
/**
|
627 |
-
* There needs to be at least 1 to address, or else the mail won't send.
|
628 |
-
* This method modifies the data that will be sent via either Rest
|
629 |
-
*/
|
630 |
-
public function updateMissingTo( $data ) {
|
631 |
-
if ( $this->smtpapi->to && (count( $this->smtpapi->to ) > 0) ) {
|
632 |
-
$data['to'] = $this->getFrom();
|
633 |
-
}
|
634 |
-
|
635 |
-
return $data;
|
636 |
-
}
|
637 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Exception.php
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace SendGrid;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* An exception thrown when SendGrid does not return a 200
|
7 |
-
*/
|
8 |
-
class Exception extends \Exception
|
9 |
-
{
|
10 |
-
public function getErrors()
|
11 |
-
{
|
12 |
-
return json_decode($this->message)->errors;
|
13 |
-
}
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/sendgrid-php-3.2.0/lib/SendGrid/Response.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace SendGrid;
|
4 |
-
|
5 |
-
class Response
|
6 |
-
{
|
7 |
-
public
|
8 |
-
$code,
|
9 |
-
$headers,
|
10 |
-
$raw_body,
|
11 |
-
$body;
|
12 |
-
|
13 |
-
public function __construct($code, $headers, $raw_body, $body)
|
14 |
-
{
|
15 |
-
$this->code = $code;
|
16 |
-
$this->headers = $headers;
|
17 |
-
$this->raw_body = $raw_body;
|
18 |
-
$this->body = $body;
|
19 |
-
}
|
20 |
-
|
21 |
-
public function getCode()
|
22 |
-
{
|
23 |
-
return $this->code;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getHeaders()
|
27 |
-
{
|
28 |
-
return $this->headers;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getRawBody()
|
32 |
-
{
|
33 |
-
return $this->raw_body;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getBody()
|
37 |
-
{
|
38 |
-
return $this->body;
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.editorconfig
RENAMED
File without changes
|
Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.gitignore
RENAMED
File without changes
|
Postman/Postman-Mail/{sendgrid-php-3.2.0 → sendgrid}/.travis.yml
RENAMED
File without changes
|
Postman/Postman-Mail/sendgrid/composer.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"require": {
|
3 |
+
"sendgrid/sendgrid": "~6.0"
|
4 |
+
}
|
5 |
+
}
|
Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php
CHANGED
@@ -259,7 +259,7 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler {
|
|
259 |
// the message was NOT sent successfully, generate an appropriate message for the user
|
260 |
$statusMessage = $result ['exception']->getMessage();
|
261 |
|
262 |
-
|
263 |
|
264 |
// compose the JSON response for the caller
|
265 |
$response = array(
|
259 |
// the message was NOT sent successfully, generate an appropriate message for the user
|
260 |
$statusMessage = $result ['exception']->getMessage();
|
261 |
|
262 |
+
$this->logger->debug( 'statusmessage: ' . $statusMessage );
|
263 |
|
264 |
// compose the JSON response for the caller
|
265 |
$response = array(
|
Postman/PostmanUtils.php
CHANGED
@@ -431,7 +431,7 @@ class PostmanUtils {
|
|
431 |
}
|
432 |
}
|
433 |
|
434 |
-
public static function
|
435 |
$ip = '';
|
436 |
|
437 |
if ( strpos( $_SERVER['SERVER_SOFTWARE'], 'iis' ) !== false ) {
|
@@ -442,13 +442,21 @@ class PostmanUtils {
|
|
442 |
$ip = $_SERVER['SERVER_ADDR'];
|
443 |
}
|
444 |
|
445 |
-
|
|
|
|
|
446 |
|
447 |
-
if (
|
448 |
-
|
449 |
}
|
450 |
|
451 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
}
|
453 |
}
|
454 |
PostmanUtils::staticInit();
|
431 |
}
|
432 |
}
|
433 |
|
434 |
+
public static function getServerName() {
|
435 |
$ip = '';
|
436 |
|
437 |
if ( strpos( $_SERVER['SERVER_SOFTWARE'], 'iis' ) !== false ) {
|
442 |
$ip = $_SERVER['SERVER_ADDR'];
|
443 |
}
|
444 |
|
445 |
+
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
|
446 |
+
$host = gethostbyaddr( $ip );
|
447 |
+
}
|
448 |
|
449 |
+
if ( $host == $ip || $host == false ) {
|
450 |
+
$host = filter_var( $_SERVER['HTTP_HOST'], FILTER_SANITIZE_STRING );
|
451 |
}
|
452 |
|
453 |
+
return $host ? $host : 'localhost';
|
454 |
+
}
|
455 |
+
|
456 |
+
public static function getHost( $url ) {
|
457 |
+
$host = parse_url( trim( $url ), PHP_URL_HOST );
|
458 |
+
|
459 |
+
return str_replace('www.', '', $host );
|
460 |
}
|
461 |
}
|
462 |
PostmanUtils::staticInit();
|
postman-smtp.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Post SMTP
|
5 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
6 |
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
|
7 |
-
* Version: 1.8
|
8 |
* Author: Jason Hendriks, Yehuda Hassine
|
9 |
* Text Domain: post-smtp
|
10 |
* Author URI: https://postmansmtp.com
|
@@ -71,5 +71,5 @@ function post_start( $startingMemory ) {
|
|
71 |
*/
|
72 |
function post_setupPostman() {
|
73 |
require_once 'Postman/Postman.php';
|
74 |
-
$kevinCostner = new Postman( __FILE__, '1.8' );
|
75 |
}
|
4 |
* Plugin Name: Post SMTP
|
5 |
* Plugin URI: https://wordpress.org/plugins/post-smtp/
|
6 |
* Description: Email not reliable? Post SMTP is the first and only WordPress SMTP plugin to implement OAuth 2.0 for Gmail, Hotmail and Yahoo Mail. Setup is a breeze with the Configuration Wizard and integrated Port Tester. Enjoy worry-free delivery even if your password changes!
|
7 |
+
* Version: 1.8.1
|
8 |
* Author: Jason Hendriks, Yehuda Hassine
|
9 |
* Text Domain: post-smtp
|
10 |
* Author URI: https://postmansmtp.com
|
71 |
*/
|
72 |
function post_setupPostman() {
|
73 |
require_once 'Postman/Postman.php';
|
74 |
+
$kevinCostner = new Postman( __FILE__, '1.8.1' );
|
75 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: yehudah, jasonhendriks
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
-
Tested up to: 4.9
|
7 |
-
Stable tag: 1.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -283,6 +283,17 @@ To avoid being flagged as spam, you need to prove your email isn't forged. On a
|
|
283 |
|
284 |
|
285 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
= 1.8 - 2017-12-24
|
287 |
* New: Mailgun API integration
|
288 |
* New: New filter controls
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP
|
4 |
Tags: postman smtp, postman, smtp, email, mail, mailer, email log, oauth2, gmail, google apps, hotmail, yahoo, mandrill api, sendgrid api, elastic email, office365, mailgun
|
5 |
Requires at least: 3.9
|
6 |
+
Tested up to: 4.9.4
|
7 |
+
Stable tag: 1.8.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
283 |
|
284 |
|
285 |
== Changelog ==
|
286 |
+
|
287 |
+
= 1.8.1 - 2017-12-24
|
288 |
+
* New: Sendgrid API & Client Version 6
|
289 |
+
* New: Add email log 'send to' column
|
290 |
+
* Fix: fallback emails on hosting require the '-f' parameter
|
291 |
+
* Fix: Using hostname insted of an IP
|
292 |
+
* Fix: Remove mailgun test folder ( virustotal issue )
|
293 |
+
* Fix: Additional bugs collected from support tickets.
|
294 |
+
* Added: added filters to from_name and from_email filters (local connection)
|
295 |
+
* change hostname extrect logic
|
296 |
+
|
297 |
= 1.8 - 2017-12-24
|
298 |
* New: Mailgun API integration
|
299 |
* New: New filter controls
|
style/postman-email-log.css
CHANGED
@@ -23,6 +23,12 @@ th#date {
|
|
23 |
border-bottom: 1px solid #ddd;
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
#postman-log-actions {
|
27 |
border-bottom: 1px solid #ddd;
|
28 |
}
|
23 |
border-bottom: 1px solid #ddd;
|
24 |
}
|
25 |
|
26 |
+
#postman_page_records {
|
27 |
+
padding: 10px;
|
28 |
+
line-height: normal;
|
29 |
+
height: auto;
|
30 |
+
}
|
31 |
+
|
32 |
#postman-log-actions {
|
33 |
border-bottom: 1px solid #ddd;
|
34 |
}
|