diff options
author | yehuda <yehuda@myinbox.in> | 2019-05-16 12:15:39 +0300 |
---|---|---|
committer | yehuda <yehuda@myinbox.in> | 2019-05-16 12:15:39 +0300 |
commit | 6b0c4d5d97cac613ad8218fc9f0779eec63c28e3 (patch) | |
tree | 3ac2513ad5cb08650b03f55d837cf6b1d578dd21 /Postman | |
parent | c88e7ad0b42cefd8fb7b509c8c2e355f567d9434 (diff) | |
parent | 09ad01149ef5981407149bc3c9502058482fb419 (diff) | |
download | Post-SMTP-6b0c4d5d97cac613ad8218fc9f0779eec63c28e3.zip |
Merge remote-tracking branch 'origin/dev'
Diffstat (limited to 'Postman')
89 files changed, 2232 insertions, 8356 deletions
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php new file mode 100644 index 0000000..9eee0a7 --- /dev/null +++ b/Postman/Phpmailer/PostsmtpMailer.php @@ -0,0 +1,122 @@ +<?php +require_once ABSPATH . WPINC . '/class-phpmailer.php'; +require_once ABSPATH . WPINC . '/class-smtp.php'; + +add_action('plugins_loaded', function() { + global $phpmailer; + + $phpmailer = new PostsmtpMailer(true); +}); + +class PostsmtpMailer extends PHPMailer { + + private $options; + + private $error; + + public function __construct($exceptions = null) + { + parent::__construct($exceptions); + + $this->options = PostmanOptions::getInstance(); + add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] ); + } + + public function send() + { + require_once dirname(__DIR__) . '/PostmanWpMail.php'; + + // create a PostmanWpMail instance + $postmanWpMail = new PostmanWpMail(); + $postmanWpMail->init(); + + $senderEmail = $this->options->getMessageSenderEmail(); + $senderName = $this->options->getMessageSenderName(); + + // create a PostmanMessage instance + $message = $postmanWpMail->createNewMessage(); + + $message->setFrom( $senderEmail, $senderName ); + $message->addHeaders( $this->getHeaders() ); + $message->setBodyTextPart( $this->AltBody ); + $message->setBodyHtmlPart( $this->Body ); + $message->setBody( $this->Body ); + $message->setSubject( $this->Subject ); + $message->addTo( $this->flatArray($this->getToAddresses() ) ); + $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) ); + $message->addCc( $this->flatArray($this->getCcAddresses() ) ); + $message->addBCc( $this->flatArray( $this->getBccAddresses() ) ); + $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) ); + $message->setAttachments( $this->getAttachments() ); + + // create a PostmanEmailLog instance + $log = new PostmanEmailLog(); + + $log->originalTo = $this->flatArray($this->getToAddresses() ); + $log->originalSubject = $this->Subject; + $log->originalMessage = $this->Body; + $log->originalHeaders = $this->getCustomHeaders(); + + try { + return $postmanWpMail->sendMessage( $message, $log ); + } catch (phpmailerException $exc) { + + $this->error = $exc; + + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + + } + + public function getAttachments() { + $attachments = parent::getAttachments(); + + $data = array(); + foreach ( $attachments as $attachment ) { + $data[] = $attachment[0]; + } + + return $data; + } + + private function getHeaders() { + $headers = array(); + foreach ( $this->getCustomHeaders() as $header ) { + $headers[] = "{$header[0]}: {$header[1]}"; + } + + return $headers; + } + + public function postman_wp_mail_result() { + $result = [ + 'time' => '', + 'exception' => $this->error, + 'transcript' => '', + ]; + return $result; + } + + private function flatArray($arr) { + $result = []; + foreach ( $arr as $key => $value ) { + if ( is_array( $value ) ) { + foreach ($value as $k => $v ) { + if ( empty( $v ) ) { + continue; + } + $value = $v; + } + } + + $result[] = $value; + } + + return implode(',', $result ); + } +}
\ No newline at end of file diff --git a/Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php b/Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php index 73a7e03..75d734b 100644 --- a/Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php +++ b/Postman/Postman-Auth/PostmanAbstractAuthenticationManager.php @@ -69,7 +69,7 @@ if (! class_exists ( "PostmanAbstractAuthenticationManager" )) { * Decoded the received token * This code is identical for Google and Hotmail * - * @param unknown $response + * @param mixed $response * @throws Exception */ protected function processResponse($response) { @@ -99,7 +99,7 @@ if (! class_exists ( "PostmanAbstractAuthenticationManager" )) { * * This code is identical for Google and Hotmail * - * @param unknown $client + * @param mixed $client */ protected function decodeReceivedAuthorizationToken($newtoken) { assert ( ! empty ( $newtoken ) ); diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php index bc9c274..6d5b6b5 100644 --- a/Postman/Postman-Configuration/PostmanConfigurationController.php +++ b/Postman/Postman-Configuration/PostmanConfigurationController.php @@ -12,10 +12,12 @@ class PostmanConfigurationController { // Holds the values to be used in the fields callbacks private $rootPluginFilenameAndPath; + private $importableConfiguration; + /** * Constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct( $rootPluginFilenameAndPath ) { assert( ! empty( $rootPluginFilenameAndPath ) ); @@ -94,11 +96,11 @@ class PostmanConfigurationController { /** */ private function addLocalizeScriptsToPage() { - $warning = __( 'Warning', Postman::TEXT_DOMAIN ); + $warning = __( 'Warning', 'post-smtp' ); /* translators: where %s is the name of the SMTP server */ - wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', Postman::TEXT_DOMAIN ) ) ); + wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ) ); /* translators: where %d is a port number */ - wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', Postman::TEXT_DOMAIN ) ); + wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', 'post-smtp' ) ); // user input wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_email', '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL ); @@ -131,7 +133,7 @@ class PostmanConfigurationController { * Register the Configuration screen */ public function addConfigurationSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_SLUG, array( $this, 'outputManualConfigurationContent', ) ); @@ -155,7 +157,7 @@ class PostmanConfigurationController { * Register the Setup Wizard screen */ public function addSetupWizardSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG, array( $this, 'outputWizardContent', ) ); @@ -194,14 +196,14 @@ class PostmanConfigurationController { public function outputManualConfigurationContent() { print '<div class="wrap">'; - PostmanViewController::outputChildPageHeader( __( 'Settings', Postman::TEXT_DOMAIN ), 'advanced_config' ); + PostmanViewController::outputChildPageHeader( __( 'Settings', 'post-smtp' ), 'advanced_config' ); print '<div id="config_tabs"><ul>'; - print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', Postman::TEXT_DOMAIN ) ); - print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', Postman::TEXT_DOMAIN ) ); - print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', Postman::TEXT_DOMAIN ) ); - print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', Postman::TEXT_DOMAIN ) ); - print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', Postman::TEXT_DOMAIN ) ); - print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', Postman::TEXT_DOMAIN ) ); + print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', 'post-smtp' ) ); + print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', 'post-smtp' ) ); + print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', 'post-smtp' ) ); + print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', 'post-smtp' ) ); + print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', 'post-smtp' ) ); + print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', 'post-smtp' ) ); print '</ul>'; print '<form method="post" action="options.php">'; @@ -239,29 +241,29 @@ class PostmanConfigurationController { <!-- Fallback Start --> <section id="fallback"> - <h2><?php esc_html_e( 'Failed emails fallback', Postman::TEXT_DOMAIN ); ?></h2> - <p><?php esc_html_e( 'By enable this option, if your email is fail to send Post SMTP will try to use the SMTP service you define here.', Postman::TEXT_DOMAIN ); ?></p> + <h2><?php esc_html_e( 'Failed emails fallback', 'post-smtp' ); ?></h2> + <p><?php esc_html_e( 'By enable this option, if your email is fail to send Post SMTP will try to use the SMTP service you define here.', 'post-smtp' ); ?></p> <table class="form-table"> <tr valign=""> - <th scope="row"><?php _e( 'Use Fallback?', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Use Fallback?', 'post-smtp' ); ?></th> <td> <label> <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio" value="no"<?php echo checked( $this->options->getFallbackIsEnabled(), 'no' ); ?>> - <?php _e( 'No', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'No', 'post-smtp' ); ?> </label> <label> <?php $checked = checked( $this->options->getFallbackIsEnabled(), 'yes', false ); ?> <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_ENABLED; ?>]" type="radio" value="yes"<?php echo checked( $this->options->getFallbackIsEnabled(), 'yes' ); ?>> - <?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'Yes', 'post-smtp' ); ?> </label> </td> </tr> <tr> - <th scope="row"><?php _e('Outgoing Mail Server', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('Outgoing Mail Server', 'post-smtp' ); ?></th> <?php $host = $this->options->getFallbackHostname(); ?> <td> <input type="text" id="fallback-smtp-host" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_HOSTNAME; ?>]" @@ -270,7 +272,7 @@ class PostmanConfigurationController { </tr> <tr> - <th scope="row"><?php _e('Mail Server Port', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('Mail Server Port', 'post-smtp' ); ?></th> <?php $port = $this->options->getFallbackPort(); ?> <td> <input type="number" id="fallback-smtp-port" name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_PORT; ?>]" @@ -279,12 +281,12 @@ class PostmanConfigurationController { </tr> <tr> - <th scope="row"><?php _e('Security', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('Security', 'post-smtp' ); ?></th> <?php $security_options = array( - 'none' => __( 'None', Postman::TEXT_DOMAIN ), - 'ssl' => __( 'SSL', Postman::TEXT_DOMAIN ), - 'tls' => __( 'TLS', Postman::TEXT_DOMAIN ), + 'none' => __( 'None', 'post-smtp' ), + 'ssl' => __( 'SSL', 'post-smtp' ), + 'tls' => __( 'TLS', 'post-smtp' ), ); ?> <td> @@ -302,36 +304,36 @@ class PostmanConfigurationController { </tr> <tr> - <th scope="row"><?php _e('From Email', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('From Email', 'post-smtp' ); ?></th> <td> <input type="email" id="fallback-smtp-from-email" value="<?php echo $this->options->getFallbackFromEmail(); ?>" name="postman_options[<?php echo PostmanOptions::FALLBACK_FROM_EMAIL; ?>]" > <br> - <small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.", Postman::TEXT_DOMAIN ); ?></small> + <small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.", 'post-smtp' ); ?></small> </td> </tr> <tr valign=""> - <th scope="row"><?php _e( 'Use SMTP Authentication?', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Use SMTP Authentication?', 'post-smtp' ); ?></th> <td> <label> <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]" type="radio" value="none"<?php checked( $this->options->getFallbackAuth(), 'none' ); ?>> - <?php _e( 'No', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'No', 'post-smtp' ); ?> </label> <label> <input name="postman_options[<?php echo PostmanOptions::FALLBACK_SMTP_USE_AUTH; ?>]" type="radio" value="login"<?php checked( $this->options->getFallbackAuth(), 'login' ); ?>> - <?php _e( 'Yes', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'Yes', 'post-smtp' ); ?> </label> </td> </tr> <tr> - <th scope="row"><?php _e('User name', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('User name', 'post-smtp' ); ?></th> <td> <input type="text" id="fallback-smtp-username" value="<?php echo $this->options->getFallbackUsername(); ?>" @@ -341,7 +343,7 @@ class PostmanConfigurationController { </tr> <tr> - <th scope="row"><?php _e('Password', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e('Password', 'post-smtp' ); ?></th> <td> <input type="password" id="fallback-smtp-password" value="<?php echo PostmanUtils::obfuscatePassword( $this->options->getFallbackPassword() ); ?>" @@ -408,7 +410,7 @@ class PostmanConfigurationController { // construct Wizard print '<div class="wrap">'; - PostmanViewController::outputChildPageHeader( __( 'Setup Wizard', Postman::TEXT_DOMAIN ) ); + PostmanViewController::outputChildPageHeader( __( 'Setup Wizard', 'post-smtp' ) ); print '<form id="postman_wizard" method="post" action="options.php">'; @@ -440,12 +442,12 @@ class PostmanConfigurationController { settings_fields( PostmanAdminController::SETTINGS_GROUP_NAME ); // Wizard Step 0 - printf( '<h5>%s</h5>', _x( 'Import Configuration', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', _x( 'Import Configuration', 'Wizard Step Title', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', _x( 'Import configuration from another plugin?', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'If you had a working configuration with another Plugin, the Setup Wizard can begin with those settings.', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', _x( 'Import configuration from another plugin?', 'Wizard Step Title', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'If you had a working configuration with another Plugin, the Setup Wizard can begin with those settings.', 'post-smtp' ) ); print '<table class="input_auth_type">'; - printf( '<tr><td><input type="radio" id="import_none" name="input_plugin" value="%s" checked="checked"></input></td><td><label> %s</label></td></tr>', 'none', __( 'None', Postman::TEXT_DOMAIN ) ); + printf( '<tr><td><input type="radio" id="import_none" name="input_plugin" value="%s" checked="checked"></input></td><td><label> %s</label></td></tr>', 'none', __( 'None', 'post-smtp' ) ); if ( $this->importableConfiguration->isImportAvailable() ) { foreach ( $this->importableConfiguration->getAvailableOptions() as $options ) { @@ -456,20 +458,20 @@ class PostmanConfigurationController { print '</fieldset>'; // Wizard Step 1 - printf( '<h5>%s</h5>', _x( 'Sender Details', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', _x( 'Sender Details', 'Wizard Step Title', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', _x( 'Who is the mail coming from?', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'Enter the email address and name you\'d like to send mail as.', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'Please note that to prevent abuse, many email services will <em>not</em> let you send from an email address other than the one you authenticate with.', Postman::TEXT_DOMAIN ) ); - printf( '<label for="postman_options[sender_email]">%s</label>', __( 'Email Address', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', _x( 'Who is the mail coming from?', 'Wizard Step Title', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'Enter the email address and name you\'d like to send mail as.', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'Please note that to prevent abuse, many email services will <em>not</em> let you send from an email address other than the one you authenticate with.', 'post-smtp' ) ); + printf( '<label for="postman_options[sender_email]">%s</label>', __( 'Email Address', 'post-smtp' ) ); print $this->settingsRegistry->from_email_callback(); print '<br/>'; - printf( '<label for="postman_options[sender_name]">%s</label>', __( 'Name', Postman::TEXT_DOMAIN ) ); + printf( '<label for="postman_options[sender_name]">%s</label>', __( 'Name', 'post-smtp' ) ); print $this->settingsRegistry->sender_name_callback(); print '</fieldset>'; // Wizard Step 2 - printf( '<h5>%s</h5>', __( 'Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) ); print '<fieldset>'; foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) { $transport->printWizardMailServerHostnameStep(); @@ -477,11 +479,11 @@ class PostmanConfigurationController { print '</fieldset>'; // Wizard Step 3 - printf( '<h5>%s</h5>', __( 'Connectivity Test', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Connectivity Test', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', __( 'How will the connection to the mail server be established?', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'Your connection settings depend on what your email service provider offers, and what your WordPress host allows.', Postman::TEXT_DOMAIN ) ); - printf( '<p id="connectivity_test_status">%s: <span id="port_test_status">%s</span></p>', __( 'Connectivity Test', Postman::TEXT_DOMAIN ), _x( 'Ready', 'TCP Port Test Status', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', __( 'How will the connection to the mail server be established?', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'Your connection settings depend on what your email service provider offers, and what your WordPress host allows.', 'post-smtp' ) ); + printf( '<p id="connectivity_test_status">%s: <span id="port_test_status">%s</span></p>', __( 'Connectivity Test', 'post-smtp' ), _x( 'Ready', 'TCP Port Test Status', 'post-smtp' ) ); printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) ); printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TRANSPORT_TYPE ); printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PORT ); @@ -489,27 +491,27 @@ class PostmanConfigurationController { printf( '<input type="hidden" id="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::AUTHENTICATION_TYPE ); print '<p id="wizard_recommendation"></p>'; /* Translators: Where %1$s is the socket identifier and %2$s is the authentication type */ - printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_socket_override" class="user_override"></table></p>', _x( 'Socket', 'A socket is the network term for host and port together', Postman::TEXT_DOMAIN ) ); - printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_auth_override" class="user_override"></table></p>', __( 'Authentication', Postman::TEXT_DOMAIN ) ); + printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_socket_override" class="user_override"></table></p>', _x( 'Socket', 'A socket is the network term for host and port together', 'post-smtp' ) ); + printf( '<p class="user_override" style="display:none"><label><span>%s:</span></label> <table id="user_auth_override" class="user_override"></table></p>', __( 'Authentication', 'post-smtp' ) ); print ('<p><span id="smtp_mitm" style="display:none; background-color:yellow"></span></p>') ; - $warning = __( 'Warning', Postman::TEXT_DOMAIN ); - $clearCredentialsWarning = __( 'This configuration option will send your authorization credentials in the clear.', Postman::TEXT_DOMAIN ); + $warning = __( 'Warning', 'post-smtp' ); + $clearCredentialsWarning = __( 'This configuration option will send your authorization credentials in the clear.', 'post-smtp' ); printf( '<p id="smtp_not_secure" style="display:none"><span style="background-color:yellow">%s: %s</span></p>', $warning, $clearCredentialsWarning ); print '</fieldset>'; // Wizard Step 4 - printf( '<h5>%s</h5>', __( 'Authentication', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Authentication', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', __( 'How will you prove your identity to the mail server?', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', __( 'How will you prove your identity to the mail server?', 'post-smtp' ) ); foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) { $transport->printWizardAuthenticationStep(); } print '</fieldset>'; // Wizard Step 5 - Notificiations - printf( '<h5>%s</h5>', __( 'Notifications', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Notifications', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', __( 'Select a notify service to notify you when an email is failed to delivered.', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', __( 'Select a notify service to notify you when an email is failed to delivered.', 'post-smtp' ) ); ?> <select id="input_notification_service" class="input_notification_service" name="postman_options[notification_service]"> @@ -518,17 +520,17 @@ class PostmanConfigurationController { <option value="slack">Slack</option> </select> <div id="pushover_cred" style="display: none;"> - <h2><?php _e( 'Pushover Credentials', Postman::TEXT_DOMAIN ); ?></h2> + <h2><?php _e( 'Pushover Credentials', 'post-smtp' ); ?></h2> <table class="form-table"> <tbody> <tr> - <th scope="row"><?php _e( 'Pushover User Key', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Pushover User Key', 'post-smtp' ); ?></th> <td> <input type="password" id="pushover_user" name="postman_options[pushover_user]" value=""> </td> </tr> <tr> - <th scope="row"><?php _e( 'Pushover App Token', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Pushover App Token', 'post-smtp' ); ?></th> <td> <input type="password" id="pushover_token" name="postman_options[pushover_token]" value=""> </td> @@ -537,15 +539,15 @@ class PostmanConfigurationController { </table> </div> <div id="slack_cred" style="display: none;"> - <h2><?php _e( 'Slack Credentials', Postman::TEXT_DOMAIN ); ?></h2> + <h2><?php _e( 'Slack Credentials', 'post-smtp' ); ?></h2> <table class="form-table"> <tbody> <tr> - <th scope="row"><?php _e( 'Slack webhook', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Slack webhook', 'post-smtp' ); ?></th> <td> <input type="password" id="slack_token" name="postman_options[slack_token]" value=""> <a target="_blank" class="" href="https://slack.postmansmtp.com/"> - <?php _e( 'Get your webhook URL here.', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'Get your webhook URL here.', 'post-smtp' ); ?> </a> </td> </tr> @@ -554,20 +556,20 @@ class PostmanConfigurationController { </div> <div id="use-chrome-extension"> - <h2><?php _e( 'Push To Chrome Extension', Postman::TEXT_DOMAIN ); ?></h2> + <h2><?php _e( 'Push To Chrome Extension', 'post-smtp' ); ?></h2> <table class="form-table"> <tbody> <tr> - <th scope="row"><?php _e( 'This is an extra notification to the selection above', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'This is an extra notification to the selection above', 'post-smtp' ); ?></th> <td> <input type="checkbox" id="notification_use_chrome" name="postman_options[notification_use_chrome]"> <a target="_blank" class="" href="https://chrome.google.com/webstore/detail/npklmbkpbknkmbohdbpikeidiaekjoch"> - <?php _e( 'You can download the chrome extensiom here.', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'You can download the chrome extension here.', 'post-smtp' ); ?> </a> </td> </tr> <tr> - <th scope="row"><?php _e( 'Your UID as you see in the extension.', Postman::TEXT_DOMAIN ); ?></th> + <th scope="row"><?php _e( 'Your UID as you see in the extension.', 'post-smtp' ); ?></th> <td> <input type="password" id="notification_chrome_uid" name="postman_options[notification_chrome_uid]" value=""> </td> @@ -580,15 +582,22 @@ class PostmanConfigurationController { print '</fieldset>'; // Wizard Step 6 - printf( '<h5>%s</h5>', _x( 'Finish', 'The final step of the Wizard', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', _x( 'Finish', 'The final step of the Wizard', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', _x( 'You\'re Done!', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', _x( 'You\'re Done!', 'Wizard Step Title', 'post-smtp' ) ); print '<section>'; - printf( '<p>%s</p>', __( 'Click Finish to save these settings, then:', Postman::TEXT_DOMAIN ) ); + printf( '<p>%s</p>', __( 'Click Finish to save these settings, then:', 'post-smtp' ) ); print '<ul style="margin-left: 20px">'; - printf( '<li class="wizard-auth-oauth2">%s</li>', __( 'Grant permission with the Email Provider for Postman to send email and', Postman::TEXT_DOMAIN ) ); - printf( '<li>%s</li>', __( 'Send yourself a Test Email to make sure everything is working!', Postman::TEXT_DOMAIN ) ); + printf( '<li class="wizard-auth-oauth2">%s</li>', __( 'Grant permission with the Email Provider for Postman to send email and', 'post-smtp' ) ); + printf( '<li>%s</li>', __( 'Send yourself a Test Email to make sure everything is working!', 'post-smtp' ) ); print '</ul>'; + + // Get PHPmailer recommendation + Postman::getMailerTypeRecommend(); + + $in_wizard = true; + include_once POST_PATH . '/Postman/extra/donation.php'; + print '</section>'; print '</fieldset>'; print '</form>'; @@ -730,7 +739,7 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { wp_send_json_success( $response ); } else { /* translators: where %s is the URL to the Connectivity Test page */ - $configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', Postman::TEXT_DOMAIN ), PostmanViewController::getPageUrl( PostmanViewController::PORT_TEST_SLUG ) ); + $configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', 'post-smtp' ), PostmanViewController::getPageUrl( PostmanViewController::PORT_TEST_SLUG ) ); $response ['configuration'] = $configuration; if ( $this->logger->isTrace() ) { $this->logger->trace( 'configuration:' ); @@ -745,8 +754,8 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { * // ask a transport if they support it, and if they do at what priority is it * // configure for the highest priority you find * - * @param unknown $queryHostData - * @return unknown + * @param mixed $queryHostData + * @return mixed */ private function getWinningRecommendation( $sockets, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) { foreach ( $sockets as $socket ) { @@ -758,11 +767,11 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { /** * - * @param PostmanSocket $socket - * @param unknown $userSocketOverride - * @param unknown $userAuthOverride - * @param unknown $originalSmtpServer - * @return Ambigous <NULL, unknown, string> + * @param PostmanWizardSocket $socket + * @param mixed $userSocketOverride + * @param mixed $userAuthOverride + * @param mixed $originalSmtpServer + * @return mixed */ private function getWin( PostmanWizardSocket $socket, $userSocketOverride, $userAuthOverride, $originalSmtpServer ) { static $recommendationPriority = - 1; @@ -790,7 +799,7 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { /** * - * @param unknown $queryHostData + * @param mixed $queryHostData * @return multitype: */ private function createOverrideMenus( $sockets, $winningRecommendation, $userSocketOverride, $userAuthOverride ) { @@ -815,9 +824,9 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { /** * * @param PostmanWizardSocket $socket - * @param unknown $winningRecommendation - * @param unknown $userSocketOverride - * @param unknown $userAuthOverride + * @param mixed $winningRecommendation + * @param mixed $userSocketOverride + * @param mixed $userAuthOverride */ private function createOverrideMenu( PostmanWizardSocket $socket, $winningRecommendation, $userSocketOverride, $userAuthOverride ) { if ( $socket->success ) { diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php index 7882d43..84305a3 100644 --- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php @@ -28,23 +28,28 @@ class PostmanSettingsRegistry { ) ); // Sanitize - add_settings_section( 'transport_section', __( 'Transport', Postman::TEXT_DOMAIN ), array( + add_settings_section( 'transport_section', __( 'Transport', 'post-smtp' ), array( $this, 'printTransportSectionInfo', ), 'transport_options' ); - add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', Postman::TEXT_DOMAIN ), array( - $this, - 'transport_type_callback', - ), 'transport_options', 'transport_section' ); + add_settings_field( PostmanOptions::TRANSPORT_TYPE, _x( 'Type', '(i.e.) What kind is it?', 'post-smtp' ), array( + $this, + 'transport_type_callback', + ), 'transport_options', 'transport_section' ); + + add_settings_field( 'smtp_mailers', __( 'Mailer Type', 'post-smtp' ), array( + $this, + 'smtp_mailer_callback', + ), 'transport_options', 'transport_section' ); // the Message From section - add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::MESSAGE_FROM_SECTION, _x( 'From Address', 'The Message Sender Email Address', 'post-smtp' ), array( $this, 'printMessageFromSectionInfo', ), PostmanAdminController::MESSAGE_FROM_OPTIONS ); - add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::MESSAGE_SENDER_EMAIL, __( 'Email Address', 'post-smtp' ), array( $this, 'from_email_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); @@ -54,7 +59,7 @@ class PostmanSettingsRegistry { 'prevent_from_email_override_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); - add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::MESSAGE_SENDER_NAME, __( 'Name', 'post-smtp' ), array( $this, 'sender_name_callback', ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); @@ -65,38 +70,38 @@ class PostmanSettingsRegistry { ), PostmanAdminController::MESSAGE_FROM_OPTIONS, PostmanAdminController::MESSAGE_FROM_SECTION ); // the Additional Addresses section - add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::MESSAGE_SECTION, __( 'Additional Email Addresses', 'post-smtp' ), array( $this, 'printMessageSectionInfo', ), PostmanAdminController::MESSAGE_OPTIONS ); - add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::REPLY_TO, __( 'Reply-To', 'post-smtp' ), array( $this, 'reply_to_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::FORCED_TO_RECIPIENTS, __( 'To Recipient(s)', 'post-smtp' ), array( $this, 'to_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::FORCED_CC_RECIPIENTS, __( 'Carbon Copy Recipient(s)', 'post-smtp' ), array( $this, 'cc_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); - add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::FORCED_BCC_RECIPIENTS, __( 'Blind Carbon Copy Recipient(s)', 'post-smtp' ), array( $this, 'bcc_callback', ), PostmanAdminController::MESSAGE_OPTIONS, PostmanAdminController::MESSAGE_SECTION ); // the Additional Headers section - add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::MESSAGE_HEADERS_SECTION, __( 'Additional Headers', 'post-smtp' ), array( $this, 'printAdditionalHeadersSectionInfo', ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS ); - add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::ADDITIONAL_HEADERS, __( 'Custom Headers', 'post-smtp' ), array( $this, 'headers_callback', ), PostmanAdminController::MESSAGE_HEADERS_OPTIONS, PostmanAdminController::MESSAGE_HEADERS_SECTION ); @@ -104,123 +109,123 @@ class PostmanSettingsRegistry { // Fallback // the Email Validation section - add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::EMAIL_VALIDATION_SECTION, __( 'Validation', 'post-smtp' ), array( $this, 'printEmailValidationSectionInfo', ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS ); - add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Email Address', 'post-smtp' ), array( $this, 'disable_email_validation_callback', ), PostmanAdminController::EMAIL_VALIDATION_OPTIONS, PostmanAdminController::EMAIL_VALIDATION_SECTION ); // the Logging section - add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::LOGGING_SECTION, __( 'Email Log Settings', 'post-smtp' ), array( $this, 'printLoggingSectionInfo', ), PostmanAdminController::LOGGING_OPTIONS ); - add_settings_field( 'logging_status', __( 'Enable Logging', Postman::TEXT_DOMAIN ), array( + add_settings_field( 'logging_status', __( 'Enable Logging', 'post-smtp' ), array( $this, 'loggingStatusInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); - add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), array( + add_settings_field( 'logging_max_entries', __( 'Maximum Log Entries', 'post-smtp' ), array( $this, 'loggingMaxEntriesInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); - add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::TRANSCRIPT_SIZE, __( 'Maximum Transcript Size', 'post-smtp' ), array( $this, 'transcriptSizeInputField', ), PostmanAdminController::LOGGING_OPTIONS, PostmanAdminController::LOGGING_SECTION ); // the Network section - add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::NETWORK_SECTION, __( 'Network Settings', 'post-smtp' ), array( $this, 'printNetworkSectionInfo', ), PostmanAdminController::NETWORK_OPTIONS ); - add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( 'connection_timeout', _x( 'TCP Connection Timeout (sec)', 'Configuration Input Field', 'post-smtp' ), array( $this, 'connection_timeout_callback', ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION ); - add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( 'read_timeout', _x( 'TCP Read Timeout (sec)', 'Configuration Input Field', 'post-smtp' ), array( $this, 'read_timeout_callback', ), PostmanAdminController::NETWORK_OPTIONS, PostmanAdminController::NETWORK_SECTION ); // the Advanced section - add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::ADVANCED_SECTION, _x( 'Miscellaneous Settings', 'Configuration Section Title', 'post-smtp' ), array( $this, 'printAdvancedSectionInfo', ), PostmanAdminController::ADVANCED_OPTIONS ); - add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::LOG_LEVEL, _x( 'PHP Log Level', 'Configuration Input Field', 'post-smtp' ), array( $this, 'log_level_callback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::RUN_MODE, _x( 'Delivery Mode', 'Configuration Input Field', 'post-smtp' ), array( $this, 'runModeCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::STEALTH_MODE, _x( 'Stealth Mode', 'This mode removes the Postman X-Mailer signature from emails', 'post-smtp' ), array( $this, 'stealthModeCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::TEMPORARY_DIRECTORY, __( 'Temporary Directory', 'post-smtp' ), array( $this, 'temporaryDirectoryCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); // Notifications - add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title', 'post-smtp' ), array( $this, 'printNotificationsSectionInfo', ), PostmanAdminController::NOTIFICATIONS_OPTIONS ); - add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field', 'post-smtp' ), array( $this, 'notification_service_callback', ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); // Pushover - add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array( + add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title', 'post-smtp' ), array( $this, 'printNotificationsSectionInfo', ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED ); - add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field', 'post-smtp' ), array( $this, 'pushover_user_callback', ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' ); - add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field', 'post-smtp' ), array( $this, 'pushover_token_callback', ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' ); // Slack - add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title', Postman::TEXT_DOMAIN ), array( + add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title', 'post-smtp' ), array( $this, 'printNotificationsSectionInfo', ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED ); - add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field', 'post-smtp' ), array( $this, 'slack_token_callback', ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' ); - add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', 'post-smtp' ), array( $this, 'notification_use_chrome_callback', ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); - add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', 'post-smtp' ), array( $this, 'notification_chrome_uid_callback', ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); @@ -232,31 +237,31 @@ class PostmanSettingsRegistry { * Print the Transport section info */ public function printTransportSectionInfo() { - print __( 'Choose SMTP or a vendor-specific API:', Postman::TEXT_DOMAIN ); + print __( 'Choose SMTP or a vendor-specific API:', 'post-smtp' ); } public function printLoggingSectionInfo() { - print __( 'Configure the delivery audit log:', Postman::TEXT_DOMAIN ); + print __( 'Configure the delivery audit log:', 'post-smtp' ); } /** * Print the Section text */ public function printMessageFromSectionInfo() { - print sprintf( __( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); + print sprintf( __( 'This address, like the <b>letterhead</b> printed on a letter, identifies the sender to the recipient. Change this when you are sending on behalf of someone else, for example to use Google\'s <a href="%s">Send Mail As</a> feature. Other plugins, especially Contact Forms, may override this field to be your visitor\'s address.', 'post-smtp' ), 'https://support.google.com/mail/answer/22370?hl=en' ); } /** * Print the Section text */ public function printMessageSectionInfo() { - print __( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.', Postman::TEXT_DOMAIN ); + print __( 'Separate multiple <b>to</b>/<b>cc</b>/<b>bcc</b> recipients with commas.', 'post-smtp' ); } /** * Print the Section text */ public function printNetworkSectionInfo() { - print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', Postman::TEXT_DOMAIN ); + print __( 'Increase the timeouts if your host is intermittenly failing to send mail. Be careful, this also correlates to how long your user must wait if the mail server is unreachable.', 'post-smtp' ); } /** @@ -275,14 +280,14 @@ class PostmanSettingsRegistry { * Print the Section text */ public function printAdditionalHeadersSectionInfo() { - print __( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.', Postman::TEXT_DOMAIN ); + print __( 'Specify custom headers (e.g. <code>X-MC-Tags: wordpress-site-A</code>), one per line. Use custom headers with caution as they can negatively affect your Spam score.', 'post-smtp' ); } /** * Print the Email Validation Description */ public function printEmailValidationSectionInfo() { - print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', Postman::TEXT_DOMAIN ); + print __( 'E-mail addresses can be validated before sending e-mail, however this may fail with some newer domains.', 'post-smtp' ); } /** @@ -297,6 +302,22 @@ class PostmanSettingsRegistry { print '</select>'; } + /** + * Get the settings option array and print one of its values + */ + public function smtp_mailer_callback() { + $smtp_mailers = PostmanOptions::SMTP_MAILERS; + $current_smtp_mailer = $this->options->getSmtpMailer(); + printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, 'smtp_mailers' ); + foreach ( $smtp_mailers as $key => $smtp_mailer ) { + printf( '<option class="input_tx_type_%1$s" value="%1$s" %3$s>%2$s</option>', $key, $smtp_mailer, $current_smtp_mailer == $key ? 'selected="selected"' : '' ); + } + print '</select>'; + ?> + <p class="description" id="mailer-type-description"><?php _e( 'Beta Feature: Change this to <strong>PHPMailer</strong> only if you see <code>wp_mail</code> conflict message, conflicts when another plugin is activated, and <strong><u>sometimes</u></strong> spam issues.', 'post-smtp' ); ?></p> + <?php + } + /** * Get the settings option array and print one of its values */ @@ -308,21 +329,21 @@ class PostmanSettingsRegistry { */ public function prevent_from_name_override_callback() { $enforced = $this->options->isPluginSenderNameEnforced(); - printf( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) ); + printf( '<input type="checkbox" id="input_prevent_sender_name_override" name="postman_options[prevent_sender_name_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', 'post-smtp' ) ); } /** * Get the settings option array and print one of its values */ public function from_email_callback() { - printf( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="email" id="input_sender_email" name="postman_options[sender_email]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getMessageSenderEmail() ? esc_attr( $this->options->getMessageSenderEmail() ) : '', __( 'Required', 'post-smtp' ) ); } /** * Print the Section text */ public function printMessageSenderSectionInfo() { - print sprintf( __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ), 'https://support.google.com/mail/answer/22370?hl=en' ); + print sprintf( __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', 'post-smtp' ), 'https://support.google.com/mail/answer/22370?hl=en' ); } /** @@ -330,7 +351,7 @@ class PostmanSettingsRegistry { */ public function prevent_from_email_override_callback() { $enforced = $this->options->isPluginSenderEmailEnforced(); - printf( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', Postman::TEXT_DOMAIN ) ); + printf( '<input type="checkbox" id="input_prevent_sender_email_override" name="postman_options[prevent_sender_email_override]" %s /> %s', $enforced ? 'checked="checked"' : '', __( 'Prevent <b>plugins</b> and <b>themes</b> from changing this', 'post-smtp' ) ); } /** @@ -343,8 +364,8 @@ class PostmanSettingsRegistry { $disabled = 'disabled="disabled" '; } printf( '<select ' . $disabled . 'id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::MAIL_LOG_ENABLED_OPTION ); - printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'Yes', Postman::TEXT_DOMAIN ) ); - printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'No', Postman::TEXT_DOMAIN ) ); + printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_YES, $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'Yes', 'post-smtp' ) ); + printf( '<option value="%s" %s>%s</option>', PostmanOptions::MAIL_LOG_ENABLED_OPTION_NO, ! $this->options->isMailLoggingEnabled() ? 'selected="selected"' : '', __( 'No', 'post-smtp' ) ); printf( '</select>' ); } public function loggingMaxEntriesInputField() { @@ -354,7 +375,7 @@ class PostmanSettingsRegistry { $inputOptionsSlug = PostmanOptions::POSTMAN_OPTIONS; $inputTranscriptSlug = PostmanOptions::TRANSCRIPT_SIZE; $inputValue = $this->options->getTranscriptSize(); - $inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', Postman::TEXT_DOMAIN ); + $inputDescription = __( 'Change this value if you can\'t see the beginning of the transcript because your messages are too big.', 'post-smtp' ); printf( '<input type="text" id="input%2$s" name="%1$s[%2$s]" value="%3$s"/><br/><span class="postman_input_description">%4$s</span>', $inputOptionsSlug, $inputTranscriptSlug, $inputValue, $inputDescription ); } @@ -397,22 +418,22 @@ class PostmanSettingsRegistry { */ public function disable_email_validation_callback() { $disabled = $this->options->isEmailValidationDisabled(); - printf( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation', Postman::TEXT_DOMAIN ) ); + printf( '<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::DISABLE_EMAIL_VALIDAITON, $disabled ? 'checked="checked"' : '', __( 'Disable e-mail validation', 'post-smtp' ) ); } /** * Get the settings option array and print one of its values */ public function log_level_callback() { - $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', Postman::TEXT_DOMAIN ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' ); + $inputDescription = sprintf( __( 'Log Level specifies the level of detail written to the <a target="_blank" href="%s">WordPress Debug log</a> - view the log with <a target-"_new" href="%s">Debug</a>.', 'post-smtp' ), 'https://codex.wordpress.org/Debugging_in_WordPress', 'https://wordpress.org/plugins/debug/' ); printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::LOG_LEVEL ); $currentKey = $this->options->getLogLevel(); - $this->printSelectOption( __( 'Off', Postman::TEXT_DOMAIN ), PostmanLogger::OFF_INT, $currentKey ); - $this->printSelectOption( __( 'Trace', Postman::TEXT_DOMAIN ), PostmanLogger::TRACE_INT, $currentKey ); - $this->printSelectOption( __( 'Debug', Postman::TEXT_DOMAIN ), PostmanLogger::DEBUG_INT, $currentKey ); - $this->printSelectOption( __( 'Info', Postman::TEXT_DOMAIN ), PostmanLogger::INFO_INT, $currentKey ); - $this->printSelectOption( __( 'Warning', Postman::TEXT_DOMAIN ), PostmanLogger::WARN_INT, $currentKey ); - $this->printSelectOption( __( 'Error', Postman::TEXT_DOMAIN ), PostmanLogger::ERROR_INT, $currentKey ); + $this->printSelectOption( __( 'Off', 'post-smtp' ), PostmanLogger::OFF_INT, $currentKey ); + $this->printSelectOption( __( 'Trace', 'post-smtp' ), PostmanLogger::TRACE_INT, $currentKey ); + $this->printSelectOption( __( 'Debug', 'post-smtp' ), PostmanLogger::DEBUG_INT, $currentKey ); + $this->printSelectOption( __( 'Info', 'post-smtp' ), PostmanLogger::INFO_INT, $currentKey ); + $this->printSelectOption( __( 'Warning', 'post-smtp' ), PostmanLogger::WARN_INT, $currentKey ); + $this->printSelectOption( __( 'Error', 'post-smtp' ), PostmanLogger::ERROR_INT, $currentKey ); printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } @@ -421,9 +442,9 @@ class PostmanSettingsRegistry { printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE ); $currentKey = $this->options->getNotificationService(); - $this->printSelectOption( __( 'Email', Postman::TEXT_DOMAIN ), 'default', $currentKey ); - $this->printSelectOption( __( 'Pushover', Postman::TEXT_DOMAIN ), 'pushover', $currentKey ); - $this->printSelectOption( __( 'Slack', Postman::TEXT_DOMAIN ), 'slack', $currentKey ); + $this->printSelectOption( __( 'Email', 'post-smtp' ), 'default', $currentKey ); + $this->printSelectOption( __( 'Pushover', 'post-smtp' ), 'pushover', $currentKey ); + $this->printSelectOption( __( 'Slack', 'post-smtp' ), 'slack', $currentKey ); printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } @@ -446,7 +467,7 @@ class PostmanSettingsRegistry { public function slack_token_callback() { printf( '<input type="password" id="slack_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SLACK_TOKEN, $this->options->getSlackToken() ); - echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here', Postman::TEXT_DOMAIN ) . '</a>'; + echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here', 'post-smtp' ) . '</a>'; } @@ -455,26 +476,26 @@ class PostmanSettingsRegistry { printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label ); } public function runModeCallback() { - $inputDescription = __( 'Delivery mode offers options useful for developing or testing.', Postman::TEXT_DOMAIN ); + $inputDescription = __( 'Delivery mode offers options useful for developing or testing.', 'post-smtp' ); printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::RUN_MODE ); $currentKey = $this->options->getRunMode(); - $this->printSelectOption( _x( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_PRODUCTION, $currentKey ); - $this->printSelectOption( __( 'Log Email and Delete', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_LOG_ONLY, $currentKey ); - $this->printSelectOption( __( 'Delete All Emails', Postman::TEXT_DOMAIN ), PostmanOptions::RUN_MODE_IGNORE, $currentKey ); + $this->printSelectOption( _x( 'Log Email and Send', 'When the server is online to the public, this is "Production" mode', 'post-smtp' ), PostmanOptions::RUN_MODE_PRODUCTION, $currentKey ); + $this->printSelectOption( __( 'Log Email and Delete', 'post-smtp' ), PostmanOptions::RUN_MODE_LOG_ONLY, $currentKey ); + $this->printSelectOption( __( 'Delete All Emails', 'post-smtp' ), PostmanOptions::RUN_MODE_IGNORE, $currentKey ); printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } public function stealthModeCallback() { - printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', Postman::TEXT_DOMAIN ) ); + printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s /> %4$s', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::STEALTH_MODE, $this->options->isStealthModeEnabled() ? 'checked="checked"' : '', __( 'Remove the Postman X-Header signature from messages', 'post-smtp' ) ); } public function temporaryDirectoryCallback() { $inputDescription = __( 'Lockfiles are written here to prevent users from triggering an OAuth 2.0 token refresh at the same time.' ); printf( '<input type="text" id="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::TEMPORARY_DIRECTORY, $this->options->getTempDirectory() ); if ( PostmanState::getInstance()->isFileLockingEnabled() ) { - printf( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __( 'Valid', Postman::TEXT_DOMAIN ), $inputDescription ); + printf( ' <span style="color:green">%s</span></br><span class="postman_input_description">%s</span>', __( 'Valid', 'post-smtp' ), $inputDescription ); } else { - printf( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __( 'Invalid', Postman::TEXT_DOMAIN ), $inputDescription ); + printf( ' <span style="color:red">%s</span></br><span class="postman_input_description">%s</span>', __( 'Invalid', 'post-smtp' ), $inputDescription ); } } @@ -496,6 +517,6 @@ class PostmanSettingsRegistry { * Get the settings option array and print one of its values */ public function port_callback( $args ) { - printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', 'post-smtp' ) ); } } diff --git a/Postman/Postman-Configuration/PostmanSmtpDiscovery.php b/Postman/Postman-Configuration/PostmanSmtpDiscovery.php index 2d568cd..44da3bb 100644 --- a/Postman/Postman-Configuration/PostmanSmtpDiscovery.php +++ b/Postman/Postman-Configuration/PostmanSmtpDiscovery.php @@ -117,7 +117,7 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) { /** * Constructor * - * @param unknown $email + * @param mixed $email */ public function __construct($email) { $this->email = $email; @@ -137,8 +137,8 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) { } /** * - * @param unknown $email - * @return Ambigous <number, boolean> + * @param mixed $email + * @return string|bool */ private function validateEmail($email) { return PostmanUtils::validateEmail ( $email ); @@ -171,7 +171,7 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) { /** * Uses getmxrr to retrieve the MX records of a hostname * - * @param unknown $hostname + * @param mixed $hostname * @return mixed|boolean */ private function findMxHostViaDns($hostname) { @@ -201,9 +201,9 @@ if (! class_exists ( 'PostmanSmtpDiscovery' )) { * This is a custom implementation of mxrr for Windows PHP installations * which don't have this method natively. * - * @param unknown $hostname - * @param unknown $mxhosts - * @param unknown $mxweight + * @param mixed $hostname + * @param mixed $mxhosts + * @param mixed $mxweight * @return boolean */ function getmxrr($hostname, &$mxhosts, &$mxweight) { diff --git a/Postman/Postman-Connectivity-Test/Postman-PortTest.php b/Postman/Postman-Connectivity-Test/Postman-PortTest.php index 6591db0..91d18f1 100644 --- a/Postman/Postman-Connectivity-Test/Postman-PortTest.php +++ b/Postman/Postman-Connectivity-Test/Postman-PortTest.php @@ -50,8 +50,8 @@ class PostmanPortTest { /** * Wrap the regDomain/getRegisteredDomain function * - * @param unknown $domain - * @return unknown|Ambigous <NULL, string, unknown, mixed> + * @param mixed $domain + * @return mixed */ private function getRegisteredDomain($hostname) { $registeredDomain = getRegisteredDomain ( $hostname ); diff --git a/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php b/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php index 7ee3c44..b423c05 100644 --- a/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php +++ b/Postman/Postman-Connectivity-Test/PostmanConnectivityTestController.php @@ -13,7 +13,7 @@ class PostmanConnectivityTestController { /** * Constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct( $rootPluginFilenameAndPath ) { assert( ! empty( $rootPluginFilenameAndPath ) ); @@ -77,7 +77,7 @@ class PostmanConnectivityTestController { * Register the Email Test screen */ public function addPortTestSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConnectivityTestController::PORT_TEST_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanConnectivityTestController::PORT_TEST_SLUG, array( $this, 'outputPortTestContent', ) ); @@ -93,26 +93,26 @@ class PostmanConnectivityTestController { function enqueuePortTestResources() { wp_enqueue_style( PostmanViewController::POSTMAN_STYLE ); wp_enqueue_script( 'postman_port_test_script' ); - $warning = __( 'Warning', Postman::TEXT_DOMAIN ); + $warning = __( 'Warning', 'post-smtp' ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME ); PostmanConnectivityTestController::addLocalizeScriptForPortTest(); } static function addLocalizeScriptForPortTest() { wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_port_test', array( - 'in_progress' => _x( 'Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN ), - 'open' => _x( 'Open', 'The port is open', Postman::TEXT_DOMAIN ), - 'closed' => _x( 'Closed', 'The port is closed', Postman::TEXT_DOMAIN ), - 'yes' => __( 'Yes', Postman::TEXT_DOMAIN ), - 'no' => __( 'No', Postman::TEXT_DOMAIN ), + 'in_progress' => _x( 'Checking..', 'The "please wait" message', 'post-smtp' ), + 'open' => _x( 'Open', 'The port is open', 'post-smtp' ), + 'closed' => _x( 'Closed', 'The port is closed', 'post-smtp' ), + 'yes' => __( 'Yes', 'post-smtp' ), + 'no' => __( 'No', 'post-smtp' ), /* translators: where %d is a port number */ - 'blocked' => __( 'No outbound route between this site and the Internet on Port %d.', Postman::TEXT_DOMAIN ), + 'blocked' => __( 'No outbound route between this site and the Internet on Port %d.', 'post-smtp' ), /* translators: where %d is a port number and %s is a hostname */ - 'try_dif_smtp' => __( 'Port %d is open, but not to %s.', Postman::TEXT_DOMAIN ), + 'try_dif_smtp' => __( 'Port %d is open, but not to %s.', 'post-smtp' ), /* translators: where %d is the port number and %s is the hostname */ - 'success' => __( 'Port %d can be used for SMTP to %s.', Postman::TEXT_DOMAIN ), - 'mitm' => sprintf( '%s: %s', __( 'Warning', Postman::TEXT_DOMAIN ), __( 'connected to %1$s instead of %2$s.', Postman::TEXT_DOMAIN ) ), + 'success' => __( 'Port %d can be used for SMTP to %s.', 'post-smtp' ), + 'mitm' => sprintf( '%s: %s', __( 'Warning', 'post-smtp' ), __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ), /* translators: where %d is a port number and %s is the URL for the Postman Gmail Extension */ - 'https_success' => __( 'Port %d can be used with the %s.', Postman::TEXT_DOMAIN ), + 'https_success' => __( 'Port %d can be used with the %s.', 'post-smtp' ), ) ); } @@ -132,46 +132,46 @@ class PostmanConnectivityTestController { public function outputPortTestContent() { print '<div class="wrap">'; - PostmanViewController::outputChildPageHeader( __( 'Connectivity Test', Postman::TEXT_DOMAIN ) ); + PostmanViewController::outputChildPageHeader( __( 'Connectivity Test', 'post-smtp' ) ); print '<p>'; - print __( 'This test determines which well-known ports are available for Postman to use.', Postman::TEXT_DOMAIN ); + print __( 'This test determines which well-known ports are available for Postman to use.', 'post-smtp' ); print '<form id="port_test_form_id" method="post">'; - printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN ) ); + printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) ); $this->port_test_hostname_callback(); - submit_button( _x( 'Begin Test', 'Button Label', Postman::TEXT_DOMAIN ), 'primary', 'begin-port-test', true ); + submit_button( _x( 'Begin Test', 'Button Label', 'post-smtp' ), 'primary', 'begin-port-test', true ); print '</form>'; print '<table id="connectivity_test_table">'; - print sprintf( '<tr><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th colspan="5">%s</th></tr>', __( 'Transport', Postman::TEXT_DOMAIN ), _x( 'Socket', 'A socket is the network term for host and port together', Postman::TEXT_DOMAIN ), __( 'Status', Postman::TEXT_DOMAIN ) . '<sup>*</sup>', __( 'Service Available', Postman::TEXT_DOMAIN ), __( 'Server ID', Postman::TEXT_DOMAIN ), __( 'Authentication', Postman::TEXT_DOMAIN ) ); + print sprintf( '<tr><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th rowspan="2">%s</th><th colspan="5">%s</th></tr>', __( 'Transport', 'post-smtp' ), _x( 'Socket', 'A socket is the network term for host and port together', 'post-smtp' ), __( 'Status', 'post-smtp' ) . '<sup>*</sup>', __( 'Service Available', 'post-smtp' ), __( 'Server ID', 'post-smtp' ), __( 'Authentication', 'post-smtp' ) ); print sprintf( '<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>', 'None', 'Login', 'Plain', 'CRAM-MD5', 'OAuth 2.0' ); $sockets = PostmanTransportRegistry::getInstance()->getSocketsForSetupWizardToProbe(); foreach ( $sockets as $socket ) { if ( $socket ['smtp'] ) { print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td class="auth_none resettable">-</td><td class="auth_login resettable">-</td><td class="auth_plain resettable">-</td><td class="auth_crammd5 resettable">-</td><td class="auth_xoauth2 resettable">-</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'] ); } else { - print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td colspan="5">%s</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'], __( 'n/a', Postman::TEXT_DOMAIN ) ); + print sprintf( '<tr id="%s"><th class="name">%s</th><td class="socket">%s:%s</td><td class="firewall resettable">-</td><td class="service resettable">-</td><td class="reported_id resettable">-</td><td colspan="5">%s</td></tr>', $socket ['id'], $socket ['transport_name'], $socket ['host'], $socket ['port'], __( 'n/a', 'post-smtp' ) ); } } print '</table>'; /* Translators: Where %s is the name of the service providing Internet connectivity test */ - printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s', Postman::TEXT_DOMAIN ), '<a target="_blank" href="https://downor.me/portquiz.net">portquiz.net</a>' ) ); + printf( '<p class="portquiz" style="display:none; font-size:0.8em">* %s</p>', sprintf( __( 'According to %s', 'post-smtp' ), '<a target="_blank" href="https://downor.me/portquiz.net">portquiz.net</a>' ) ); printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) ); print '<section id="conclusion" style="display:none">'; - print sprintf( '<h3>%s:</h3>', __( 'Summary', Postman::TEXT_DOMAIN ) ); + print sprintf( '<h3>%s:</h3>', __( 'Summary', 'post-smtp' ) ); print '<ol class="conclusion">'; print '</ol>'; print '</section>'; print '<section id="blocked-port-help" style="display:none">'; - print sprintf( '<p><b>%s</b></p>', __( 'A test with <span style="color:red">"No"</span> Service Available indicates one or more of these issues:', Postman::TEXT_DOMAIN ) ); + print sprintf( '<p><b>%s</b></p>', __( 'A test with <span style="color:red">"No"</span> Service Available indicates one or more of these issues:', 'post-smtp' ) ); print '<ol>'; - printf( '<li>%s</li>', __( 'Your web host has placed a firewall between this site and the Internet', Postman::TEXT_DOMAIN ) ); - printf( '<li>%s</li>', __( 'The SMTP hostname is wrong or the mail server does not provide service on this port', Postman::TEXT_DOMAIN ) ); + printf( '<li>%s</li>', __( 'Your web host has placed a firewall between this site and the Internet', 'post-smtp' ) ); + printf( '<li>%s</li>', __( 'The SMTP hostname is wrong or the mail server does not provide service on this port', 'post-smtp' ) ); /* translators: where (1) is the URL and (2) is the system */ - $systemBlockMessage = __( 'Your <a href="%1$s">%2$s configuration</a> is preventing outbound connections', Postman::TEXT_DOMAIN ); + $systemBlockMessage = __( 'Your <a href="%1$s">%2$s configuration</a> is preventing outbound connections', 'post-smtp' ); printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen', 'PHP' ) ); printf( '<li>%s</li>', sprintf( $systemBlockMessage, 'http://wp-mix.com/disable-external-url-requests/', 'WordPress' ) ); print '</ol></p>'; - print sprintf( '<p><b>%s</b></p>', __( 'If the issues above can not be resolved, your last option is to configure Postman to use an email account managed by your web host with an SMTP server managed by your web host.', Postman::TEXT_DOMAIN ) ); + print sprintf( '<p><b>%s</b></p>', __( 'If the issues above can not be resolved, your last option is to configure Postman to use an email account managed by your web host with an SMTP server managed by your web host.', 'post-smtp' ) ); print '</section>'; print '</div>'; } @@ -271,9 +271,9 @@ class PostmanPortTestAjaxController { /** * - * @param unknown $hostname - * @param unknown $port - * @param unknown $success + * @param mixed $hostname + * @param mixed $port + * @param mixed $success */ private function buildResponse( $hostname, $port, PostmanPortTest $portTest, $success, $transport = '' ) { $this->logger->debug( sprintf( 'testing port result for %s:%s success=%s', $hostname, $port, $success ) ); diff --git a/Postman/Postman-Controller/PostmanAdminPointer.php b/Postman/Postman-Controller/PostmanAdminPointer.php index 16bd6a2..15fb52d 100644 --- a/Postman/Postman-Controller/PostmanAdminPointer.php +++ b/Postman/Postman-Controller/PostmanAdminPointer.php @@ -13,7 +13,7 @@ if (! class_exists ( 'PostmanAdminPointer' )) { /** * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ function __construct($rootPluginFilenameAndPath) { $this->logger = new PostmanLogger ( get_class ( $this ) ); @@ -35,7 +35,7 @@ if (! class_exists ( 'PostmanAdminPointer' )) { /** * - * @param unknown $hook_suffix + * @param mixed $hook_suffix */ function wptuts_pointer_load($hook_suffix) { // only do this for administrators diff --git a/Postman/Postman-Controller/PostmanDashboardWidgetController.php b/Postman/Postman-Controller/PostmanDashboardWidgetController.php index 7393ee3..6233315 100644 --- a/Postman/Postman-Controller/PostmanDashboardWidgetController.php +++ b/Postman/Postman-Controller/PostmanDashboardWidgetController.php @@ -54,7 +54,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { public function addDashboardWidget() { // only display to the widget to administrator if (PostmanUtils::isAdmin ()) { - wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ), array ( + wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', 'post-smtp' ), array ( $this, 'printDashboardWidget' ) ); // Display function. @@ -67,7 +67,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { public function addNetworkDashboardWidget() { // only display to the widget to administrator if (PostmanUtils::isAdmin ()) { - wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', Postman::TEXT_DOMAIN ), array ( + wp_add_dashboard_widget ( 'example_dashboard_widget', __ ( 'Postman SMTP', 'post-smtp' ), array ( $this, 'printNetworkDashboardWidget' ) ); // Display function. @@ -78,8 +78,8 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { * Create the function to output the contents of our Dashboard Widget. */ public function printDashboardWidget() { - $goToSettings = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings', Postman::TEXT_DOMAIN ) ); - $goToEmailLog = sprintf ( '%s', _x ( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ) ); + $goToSettings = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl (), __ ( 'Settings', 'post-smtp' ) ); + $goToEmailLog = sprintf ( '%s', _x ( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' ) ); if ($this->options->isMailLoggingEnabled ()) { $goToEmailLog = sprintf ( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl (), $goToEmailLog ); } @@ -92,16 +92,16 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { */ public function print_postman_status() { if (! PostmanPreRequisitesCheck::isReady ()) { - printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Error: Postman is missing a required PHP library.', Postman::TEXT_DOMAIN ) ); + printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Error: Postman is missing a required PHP library.', 'post-smtp' ) ); } else if ($this->wpMailBinder->isUnboundDueToException ()) { - printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', Postman::TEXT_DOMAIN ) ); + printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', 'post-smtp' ) ); } else { if ($this->options->getRunMode () != PostmanOptions::RUN_MODE_PRODUCTION) { - printf ( '<p><span style="background-color:yellow">%s</span></p>', __ ( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', Postman::TEXT_DOMAIN ) ); + printf ( '<p><span style="background-color:yellow">%s</span></p>', __ ( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', 'post-smtp' ) ); } else if (PostmanTransportRegistry::getInstance ()->getSelectedTransport ()->isConfiguredAndReady ()) { - printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s </p>', sprintf ( _n ( '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> email.', '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance ()->getSuccessfulDeliveries (), Postman::TEXT_DOMAIN ), PostmanState::getInstance ()->getSuccessfulDeliveries () ) ); + printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s </p>', sprintf ( _n ( '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> email.', '<span style="color:green">Postman is configured</span> and has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance ()->getSuccessfulDeliveries (), 'post-smtp' ), PostmanState::getInstance ()->getSuccessfulDeliveries () ) ); } else { - printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', Postman::TEXT_DOMAIN ) ); + printf ( '<p><span style="color:red">%s</span></p>', __ ( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', 'post-smtp' ) ); } $currentTransport = PostmanTransportRegistry::getInstance ()->getActiveTransport (); $deliveryDetails = $currentTransport->getDeliveryDetails ( $this->options ); @@ -113,14 +113,14 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { * Create the function to output the contents of our Dashboard Widget. */ public function printNetworkDashboardWidget() { - printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s</p>', __ ( 'Postman is operating in per-site mode.', Postman::TEXT_DOMAIN ) ); + printf ( '<p class="wp-menu-image dashicons-before dashicons-email"> %s</p>', __ ( 'Postman is operating in per-site mode.', 'post-smtp' ) ); } /** * From http://www.hughlashbrooke.com/2014/02/wordpress-add-items-glance-widget/ * http://coffeecupweb.com/how-to-add-custom-post-types-to-at-a-glance-dashboard-widget-in-wordpress/ * - * @param unknown $items + * @param mixed $items * @return string */ function customizeAtAGlanceDashboardWidget($items = array()) { @@ -143,7 +143,7 @@ if (! class_exists ( "PostmanDashboardWidgetController" )) { $privated = intval ( $num_posts->private ); $post_type = get_post_type_object ( $type ); - $text = _n ( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $privated, Postman::TEXT_DOMAIN ); + $text = _n ( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $privated, 'post-smtp' ); $text = sprintf ( $text, number_format_i18n ( $privated ) ); $items [] = sprintf ( '<a class="%1$s-count" href="%3$s">%2$s</a>', $type, $text, PostmanUtils::getEmailLogPageUrl () ) . "\n"; diff --git a/Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php b/Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php index 2c05b3a..1260dad 100644 --- a/Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php +++ b/Postman/Postman-Controller/PostmanManageConfigurationAjaxHandler.php @@ -27,7 +27,7 @@ class PostmanWizardSocket { /** * - * @param unknown $queryHostData + * @param mixed $queryHostData */ function __construct($queryHostData) { $this->hostname = $queryHostData ['hostname']; diff --git a/Postman/Postman-Controller/PostmanWelcomeController.php b/Postman/Postman-Controller/PostmanWelcomeController.php index b43e969..869848a 100644 --- a/Postman/Postman-Controller/PostmanWelcomeController.php +++ b/Postman/Postman-Controller/PostmanWelcomeController.php @@ -19,8 +19,8 @@ class PostmanWelcomeController { // About add_dashboard_page( - __( 'Welcome', Postman::TEXT_DOMAIN ), - __( 'Welcome', Postman::TEXT_DOMAIN ), + __( 'Welcome', 'post-smtp' ), + __( 'Welcome', 'post-smtp' ), 'manage_options', 'post-about', array( $this, 'about_screen' ) @@ -28,8 +28,8 @@ class PostmanWelcomeController { // Credits add_dashboard_page( - __( 'Credits', Postman::TEXT_DOMAIN ), - __( 'Credits', Postman::TEXT_DOMAIN ), + __( 'Credits', 'post-smtp' ), + __( 'Credits', 'post-smtp' ), 'manage_options', 'post-credits', array( $this, 'credits_screen' ) @@ -72,36 +72,36 @@ class PostmanWelcomeController { } </style> <div class="wrap about-wrap"> - <h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', Postman::TEXT_DOMAIN ), $this->version ); ?></h1> - <div class="about-text"><?php printf( esc_html__( 'Thank you for updating! Post SMTP %s is bundled up and ready to take your SMTP needs to the next level!', Postman::TEXT_DOMAIN ), $this->version ); ?><br> + <h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', 'post-smtp' ), $this->version ); ?></h1> + <div class="about-text"><?php printf( esc_html__( 'Thank you for updating! Post SMTP %s is bundled up and ready to take your SMTP needs to the next level!', 'post-smtp' ), $this->version ); ?><br> <?php printf( '<strong>%s</strong>','Post SMTP support every SMTP service: Gmail/G-suite, SendGrid, Mandrill, Office365, and more...' ); ?> </div> - <div class="post-badge"><?php printf( esc_html__( 'Version %s', Postman::TEXT_DOMAIN ), $this->version ); ?></div> + <div class="post-badge"><?php printf( esc_html__( 'Version %s', 'post-smtp' ), $this->version ); ?></div> <h2 class="nav-tab-wrapper"> <a class="nav-tab nav-tab-active" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>"> - <?php esc_html_e( 'What’s New', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'What’s New', 'post-smtp' ); ?> </a><a class="nav-tab" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>"> - <?php esc_html_e( 'Credits', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'Credits', 'post-smtp' ); ?> </a> </h2> <div class="changelog"> - <h3><?php esc_html_e( 'Email Log', Postman::TEXT_DOMAIN ); ?></h3> + <h3><?php esc_html_e( 'Email Log', 'post-smtp' ); ?></h3> <div class="feature-section col two-col"> <div class="last-feature"> - <h4><?php esc_html_e( 'Email log filter', Postman::TEXT_DOMAIN ); ?></h4> + <h4><?php esc_html_e( 'Email log filter', 'post-smtp' ); ?></h4> <p> - <?php esc_html_e( 'You can easily filter by dates and search in your log.', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'You can easily filter by dates and search in your log.', 'post-smtp' ); ?> <img src="<?php echo $this->pluginUrl; ?>/images/filter-preview.gif"> </p> </div> <div> - <h4><?php esc_html_e( 'Multiple emails resend', Postman::TEXT_DOMAIN ); ?></h4> + <h4><?php esc_html_e( 'Multiple emails resend', 'post-smtp' ); ?></h4> <p> - <?php esc_html_e( 'Resend any email to the original recipient or any other emails you choose.', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'Resend any email to the original recipient or any other emails you choose.', 'post-smtp' ); ?> <img src="<?php echo $this->pluginUrl; ?>/images/resend-preview.gif"> </p> </div> @@ -109,7 +109,7 @@ class PostmanWelcomeController { </div> <div class="changelog"> - <h3><?php esc_html_e( 'The best delivery experience', Postman::TEXT_DOMAIN ); ?></h3> + <h3><?php esc_html_e( 'The best delivery experience', 'post-smtp' ); ?></h3> <div class="feature-section col one-col"> <div class="last-feature"> @@ -120,30 +120,30 @@ class PostmanWelcomeController { Supports forced recipients (cc, bcc, to) and custom email headers, SASL Support: Plain/Login/CRAM-MD5/XOAUTH2 authentication, Security Support: SMTPS and STARTTLS (SSL/TLS), - Copy configuration to other instances of Post.', Postman::TEXT_DOMAIN ); ?></p> + Copy configuration to other instances of Post.', 'post-smtp' ); ?></p> </div> </div> <div class="feature-section col three-col"> <div> - <h4><?php esc_html_e( 'Email log HTML preview', Postman::TEXT_DOMAIN ); ?></h4> - <p><?php esc_html_e( 'You can now see sent emails as HTML.', Postman::TEXT_DOMAIN ); ?></p> + <h4><?php esc_html_e( 'Email log HTML preview', 'post-smtp' ); ?></h4> + <p><?php esc_html_e( 'You can now see sent emails as HTML.', 'post-smtp' ); ?></p> </div> <div> - <h4><?php esc_html_e( 'Continues email delivery', Postman::TEXT_DOMAIN ); ?></h4> - <p><?php esc_html_e( 'if email fail to sent you will get notified using the local mail system.', Postman::TEXT_DOMAIN ); ?></p> + <h4><?php esc_html_e( 'Continues email delivery', 'post-smtp' ); ?></h4> + <p><?php esc_html_e( 'if email fail to sent you will get notified using the local mail system.', 'post-smtp' ); ?></p> </div> <div class="last-feature"> - <h4><?php esc_html_e( 'The best debugging tools.', Postman::TEXT_DOMAIN ); ?></h4> - <p><?php esc_html_e( 'Full Transcripts, Connectivity Test, Diagnostic Test.', Postman::TEXT_DOMAIN ); ?></p> + <h4><?php esc_html_e( 'The best debugging tools.', 'post-smtp' ); ?></h4> + <p><?php esc_html_e( 'Full Transcripts, Connectivity Test, Diagnostic Test.', 'post-smtp' ); ?></p> </div> </div> </div> <div class="return-to-dashboard"> - <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', Postman::TEXT_DOMAIN ); ?></a> + <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', 'post-smtp' ); ?></a> </div> </div> @@ -170,36 +170,36 @@ class PostmanWelcomeController { } </style> <div class="wrap about-wrap"> - <h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', Postman::TEXT_DOMAIN ), $this->version ); ?></h1> - <div class="about-text"><?php printf( esc_html__( 'Thank you for updating! bbPress %s is waxed, polished, and ready for you to take it for a lap or two around the block!', Postman::TEXT_DOMAIN ), $this->version ); ?></div> - <div class="post-badge"><?php printf( esc_html__( 'Version %s', Postman::TEXT_DOMAIN ), $this->version ); ?></div> + <h1><?php printf( esc_html__( 'Welcome to Post SMTP %s', 'post-smtp' ), $this->version ); ?></h1> + <div class="about-text"><?php printf( esc_html__( 'Thank you for updating! bbPress %s is waxed, polished, and ready for you to take it for a lap or two around the block!', 'post-smtp' ), $this->version ); ?></div> + <div class="post-badge"><?php printf( esc_html__( 'Version %s', 'post-smtp' ), $this->version ); ?></div> <h2 class="nav-tab-wrapper"> <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-about' ), 'index.php' ) ) ); ?>" class="nav-tab"> - <?php esc_html_e( 'What’s New', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'What’s New', 'post-smtp' ); ?> </a><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'post-credits' ), 'index.php' ) ) ); ?>" class="nav-tab nav-tab-active"> - <?php esc_html_e( 'Credits', Postman::TEXT_DOMAIN ); ?> + <?php esc_html_e( 'Credits', 'post-smtp' ); ?> </a> </h2> - <p class="about-description"><?php esc_html_e( 'Post SMTP started by Jason Hendriks, Jason left the project and Yehuda Hassine (me) continue his work.', Postman::TEXT_DOMAIN ); ?></p> + <p class="about-description"><?php esc_html_e( 'Post SMTP started by Jason Hendriks, Jason left the project and Yehuda Hassine (me) continue his work.', 'post-smtp' ); ?></p> - <h4 class="wp-people-group"><?php esc_html_e( 'Project Leaders', Postman::TEXT_DOMAIN ); ?></h4> + <h4 class="wp-people-group"><?php esc_html_e( 'Project Leaders', 'post-smtp' ); ?></h4> <ul class="wp-people-group " id="wp-people-group-project-leaders"> <li class="wp-person" id="wp-person-jasonhendriks"> <a href="https://profiles.wordpress.org/jasonhendriks"><img src="https://secure.gravatar.com/avatar/8692c7b6084517a592f6cad107f7bcb0?s=60&d=mm&r=g" class="gravatar" alt="Jason Hendriks " /></a> <a class="web" href="http://profiles.wordpress.org/matt">Jason Hendriks</a> - <span class="title"><?php esc_html_e( 'Founding Developer (abandoned)', Postman::TEXT_DOMAIN ); ?></span> + <span class="title"><?php esc_html_e( 'Founding Developer (abandoned)', 'post-smtp' ); ?></span> </li> <li class="wp-person" id="wp-person-yehudah"> <a href="http://profiles.wordpress.org/yehudah"><img src="https://secure.gravatar.com/avatar/c561638d04ea8fef351f974dbb9ece39?s=60&d=mm&r=g" class="gravatar" alt="Yehuda Hassine" /></a> <a class="web" href="http://profiles.wordpress.org/yehudah">Yehuda Hassine</a> - <span class="title"><?php esc_html_e( 'Lead Developer', Postman::TEXT_DOMAIN ); ?></span> + <span class="title"><?php esc_html_e( 'Lead Developer', 'post-smtp' ); ?></span> </li> </ul> - <h4 class="wp-people-group"><?php esc_html_e( 'Top Community Members', Postman::TEXT_DOMAIN ); ?></h4> - <h5><?php esc_html_e( 'Here I will list top users that help Post SMTP grow (bugs, features, etc...)', Postman::TEXT_DOMAIN ); ?> + <h4 class="wp-people-group"><?php esc_html_e( 'Top Community Members', 'post-smtp' ); ?></h4> + <h5><?php esc_html_e( 'Here I will list top users that help Post SMTP grow (bugs, features, etc...)', 'post-smtp' ); ?> <p class="wp-credits-list"> <a href="http://profiles.wordpress.org/diegocanal">diegocanal</a>, <a href="http://profiles.wordpress.org/jyourstone">Johan Yourstone</a>, @@ -209,7 +209,7 @@ class PostmanWelcomeController { </p> <div class="return-to-dashboard"> - <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', Postman::TEXT_DOMAIN ); ?></a> + <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'postman' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Go to Post SMTP Settings', 'post-smtp' ); ?></a> </div> </div> diff --git a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php index c526113..82eb558 100644 --- a/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php +++ b/Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.php @@ -12,7 +12,7 @@ class PostmanDiagnosticTestController { /** * Constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct( $rootPluginFilenameAndPath ) { assert( ! empty( $rootPluginFilenameAndPath ) ); @@ -77,7 +77,7 @@ class PostmanDiagnosticTestController { * Register the Diagnostics screen */ public function addDiagnosticsSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanDiagnosticTestController::DIAGNOSTICS_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanDiagnosticTestController::DIAGNOSTICS_SLUG, array( $this, 'outputDiagnosticsContent', ) ); @@ -98,14 +98,14 @@ class PostmanDiagnosticTestController { // test features print '<div class="wrap">'; - PostmanViewController::outputChildPageHeader( __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) ); + PostmanViewController::outputChildPageHeader( __( 'Diagnostic Test', 'post-smtp' ) ); - printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', Postman::TEXT_DOMAIN ) ); + printf( '<h4>%s</h4>', __( 'Are you having issues with Postman?', 'post-smtp' ) ); /* translators: where %1$s and %2$s are the URLs to the Troubleshooting and Support Forums on WordPress.org */ - printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) ); - printf( '<h4>%s</h4>', __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) ); - printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:', Postman::TEXT_DOMAIN ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) ); - printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', Postman::TEXT_DOMAIN ) ); + printf( '<p style="margin:0 10px">%s</p>', sprintf( __( 'Please check the <a href="%1$s">troubleshooting and error messages</a> page and the <a href="%2$s">support forum</a>.', 'post-smtp' ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) ); + printf( '<h4>%s</h4>', __( 'Diagnostic Test', 'post-smtp' ) ); + printf( '<p style="margin:0 10px">%s</p><br/>', sprintf( __( 'If you write for help, please include the following:', 'post-smtp' ), 'https://wordpress.org/plugins/post-smtp/other_notes/', 'https://wordpress.org/support/plugin/post-smtp' ) ); + printf( '<textarea readonly="readonly" id="diagnostic-text" cols="80" rows="15">%s</textarea>', _x( 'Checking..', 'The "please wait" message', 'post-smtp' ) ); print '</div>'; } } @@ -210,6 +210,7 @@ class PostmanGetDiagnosticsViaAjax { public function getDiagnostics() { $curl = curl_version(); $transportRegistry = PostmanTransportRegistry::getInstance(); + $this->addToDiagnostics( 'Mailer', PostmanOptions::getInstance()->getSmtpMailer() ); $this->addToDiagnostics( 'HostName', PostmanUtils::getServerName() ); $this->addToDiagnostics( 'cURL Version', $curl['version'] ); $this->addToDiagnostics( 'OpenSSL Version', $curl['ssl_version'] ); @@ -219,17 +220,15 @@ class PostmanGetDiagnosticsViaAjax { $this->addToDiagnostics( 'WordPress', (is_multisite() ? 'Multisite ' : '') . get_bloginfo( 'version' ) . ' ' . get_locale() . ' ' . get_bloginfo( 'charset', 'display' ) ); $this->addToDiagnostics( 'WordPress Theme', wp_get_theme() ); $this->addToDiagnostics( 'WordPress Plugins', $this->getActivePlugins() ); - { - $bindResult = apply_filters( 'postman_wp_mail_bind_status', null ); - $wp_mail_file_name = 'n/a'; + + $bindResult = apply_filters( 'postman_wp_mail_bind_status', null ); + $wp_mail_file_name = 'n/a'; if ( class_exists( 'ReflectionFunction' ) ) { $wp_mail = new ReflectionFunction( 'wp_mail' ); $wp_mail_file_name = realpath( $wp_mail->getFileName() ); } - if ( ! $bindResult ['bound'] ) { - $this->addToDiagnostics( 'WordPress wp_mail Owner', $wp_mail_file_name ); - } - } + + $this->addToDiagnostics( 'WordPress wp_mail Owner', $wp_mail_file_name ); $this->addToDiagnostics( 'WordPress wp_mail Filter(s)', $this->getFilters( 'wp_mail' ) ); $this->addToDiagnostics( 'WordPress wp_mail_from Filter(s)', $this->getFilters( 'wp_mail_from' ) ); $this->addToDiagnostics( 'WordPress wp_mail_from_name Filter(s)', $this->getFilters( 'wp_mail_from_name' ) ); diff --git a/Postman/Postman-Email-Log/PostmanEmailLogController.php b/Postman/Postman-Email-Log/PostmanEmailLogController.php index be08232..79751f3 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogController.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogController.php @@ -1,4 +1,5 @@ <?php +require_once dirname(__DIR__) . '/PostmanEmailLogs.php'; require_once 'PostmanEmailLogService.php'; require_once 'PostmanEmailLogView.php'; @@ -77,8 +78,7 @@ class PostmanEmailLogController { // get the email address of the recipient from the HTTP Request $postid = $this->getRequestParameter( 'email' ); if ( ! empty( $postid ) ) { - $post = get_post( $postid ); - $meta_values = get_post_meta( $postid ); + $meta_values = PostmanEmailLogs::get_data( $postid ); if ( isset( $_POST['mail_to'] ) && ! empty( $_POST['mail_to'] ) ) { $emails = explode( ',', $_POST['mail_to'] ); @@ -87,7 +87,7 @@ class PostmanEmailLogController { $to = $meta_values ['original_to'] [0]; } - $success = wp_mail( $to, $meta_values ['original_subject'] [0], $meta_values ['original_message'] [0], $meta_values ['original_headers'] [0] ); + $success = wp_mail( $to, $meta_values ['original_subject'] [0], maybe_unserialize( $meta_values ['original_message'] [0] ), $meta_values ['original_headers'] [0] ); // Postman API: retrieve the result of sending this message from Postman $result = apply_filters( 'postman_wp_mail_result', null ); @@ -97,7 +97,7 @@ class PostmanEmailLogController { if ( $success ) { $this->logger->debug( 'Email was successfully re-sent' ); // the message was sent successfully, generate an appropriate message for the user - $statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', Postman::TEXT_DOMAIN ), $result ['time'] ); + $statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', 'post-smtp' ), $result ['time'] ); // compose the JSON response for the caller $response = array( @@ -134,8 +134,8 @@ class PostmanEmailLogController { /** * TODO move this somewhere reusable * - * @param unknown $parameterName - * @return unknown + * @param mixed $parameterName + * @return mixed */ private function getRequestParameter( $parameterName ) { if ( isset( $_POST [ $parameterName ] ) ) { @@ -163,7 +163,7 @@ class PostmanEmailLogController { $purger->verifyLogItemExistsAndRemove( $postid ); } $mh = new PostmanMessageHandler(); - $mh->addMessage( __( 'Mail Log Entries were deleted.', Postman::TEXT_DOMAIN ) ); + $mh->addMessage( __( 'Mail Log Entries were deleted.', 'post-smtp' ) ); } else { $this->logger->warn( sprintf( 'action "%s" not recognized', $_REQUEST ['action'] ) ); } @@ -186,7 +186,7 @@ class PostmanEmailLogController { $purger = new PostmanEmailLogPurger(); $purger->verifyLogItemExistsAndRemove( $postid ); $mh = new PostmanMessageHandler(); - $mh->addMessage( __( 'Mail Log Entry was deleted.', Postman::TEXT_DOMAIN ) ); + $mh->addMessage( __( 'Mail Log Entry was deleted.', 'post-smtp' ) ); } else { $this->logger->warn( sprintf( 'nonce "%s" failed validation', $_REQUEST ['_wpnonce'] ) ); } @@ -202,7 +202,7 @@ class PostmanEmailLogController { $this->logger->trace( 'handling view item' ); $postid = $_REQUEST ['email']; $post = get_post( $postid ); - $meta_values = get_post_meta( $postid ); + $meta_values = PostmanEmailLogs::get_data( $postid ); // https://css-tricks.com/examples/hrs/ print '<html><head><style>body {font-family: monospace;} hr { border: 0; @@ -211,29 +211,29 @@ class PostmanEmailLogController { }</style></head><body>'; print '<table>'; if ( ! empty( $meta_values ['from_header'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'From', 'Who is this message From?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['from_header'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'From', 'Who is this message From?', 'post-smtp' ), esc_html( $meta_values ['from_header'] [0] ) ); } // show the To header (it's optional) if ( ! empty( $meta_values ['to_header'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'To', 'Who is this message To?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['to_header'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'To', 'Who is this message To?', 'post-smtp' ), esc_html( $meta_values ['to_header'] [0] ) ); } // show the Cc header (it's optional) if ( ! empty( $meta_values ['cc_header'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Cc', 'Who is this message Cc\'d to?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['cc_header'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Cc', 'Who is this message Cc\'d to?', 'post-smtp' ), esc_html( $meta_values ['cc_header'] [0] ) ); } // show the Bcc header (it's optional) if ( ! empty( $meta_values ['bcc_header'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Bcc', 'Who is this message Bcc\'d to?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['bcc_header'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Bcc', 'Who is this message Bcc\'d to?', 'post-smtp' ), esc_html( $meta_values ['bcc_header'] [0] ) ); } // show the Reply-To header (it's optional) if ( ! empty( $meta_values ['reply_to_header'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __( 'Reply-To', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['reply_to_header'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', __( 'Reply-To', 'post-smtp' ), esc_html( $meta_values ['reply_to_header'] [0] ) ); } - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Date', 'What is the date today?', Postman::TEXT_DOMAIN ), $post->post_date ); - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ), esc_html( $post->post_title ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Date', 'What is the date today?', 'post-smtp' ), $post->post_date ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Subject', 'What is the subject of this message?', 'post-smtp' ), esc_html( $post->post_title ) ); // The Transport UI is always there, in more recent versions that is if ( ! empty( $meta_values ['transport_uri'] [0] ) ) { - printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Delivery-URI', 'What is the unique URI of the configuration?', Postman::TEXT_DOMAIN ), esc_html( $meta_values ['transport_uri'] [0] ) ); + printf( '<tr><th style="text-align:right">%s:</th><td>%s</td></tr>', _x( 'Delivery-URI', 'What is the unique URI of the configuration?', 'post-smtp' ), esc_html( $meta_values ['transport_uri'] [0] ) ); } print '</table>'; print '<hr/>'; @@ -260,21 +260,21 @@ class PostmanEmailLogController { $this->logger->trace( 'handling view transcript item' ); $postid = $_REQUEST ['email']; $post = get_post( $postid ); - $meta_values = get_post_meta( $postid ); + $meta_values = PostmanEmailLogs::get_data( $postid ); // https://css-tricks.com/examples/hrs/ print '<html><head><style>body {font-family: monospace;} hr { border: 0; border-bottom: 1px dashed #ccc; background: #bbb; }</style></head><body>'; - printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', Postman::TEXT_DOMAIN ) ); + printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', 'post-smtp' ) ); print '<hr/>'; print '<pre>'; if ( ! empty( $meta_values ['session_transcript'] [0] ) ) { print esc_html( $meta_values ['session_transcript'] [0] ); } else { /* Translators: Meaning "Not Applicable" */ - print __( 'n/a', Postman::TEXT_DOMAIN ); + print __( 'n/a', 'post-smtp' ); } print '</pre>'; print '</body></html>'; @@ -299,8 +299,8 @@ class PostmanEmailLogController { $this->logger->trace( 'created PostmanEmailLog admin menu item' ); /* Translators where (%s) is the name of the plugin */ - $pageTitle = sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ); - $pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ); + $pageTitle = sprintf( __( '%s Email Log', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ); + $pluginName = _x( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' ); $page = add_submenu_page( PostmanViewController::POSTMAN_MENU_SLUG, $pageTitle, $pluginName, Postman::MANAGE_POSTMAN_CAPABILITY_LOGS, 'postman_email_log', array( $this, 'postman_render_email_page' ) ); @@ -317,10 +317,10 @@ class PostmanEmailLogController { wp_enqueue_style( 'postman_email_log' ); wp_enqueue_script( 'postman_resend_email_script' ); wp_enqueue_script( 'sprintf' ); - wp_localize_script( 'postman_resend_email_script', 'postman_js_email_was_resent', __( 'Email was successfully resent (but without attachments)', Postman::TEXT_DOMAIN ) ); + wp_localize_script( 'postman_resend_email_script', 'postman_js_email_was_resent', __( 'Email was successfully resent (but without attachments)', 'post-smtp' ) ); /* Translators: Where %s is an error message */ - wp_localize_script( 'postman_resend_email_script', 'postman_js_email_not_resent', __( 'Email could not be resent. Error: %s', Postman::TEXT_DOMAIN ) ); - wp_localize_script( 'postman_resend_email_script', 'postman_js_resend_label', __( 'Resend', Postman::TEXT_DOMAIN ) ); + wp_localize_script( 'postman_resend_email_script', 'postman_js_email_not_resent', __( 'Email could not be resent. Error: %s', 'post-smtp' ) ); + wp_localize_script( 'postman_resend_email_script', 'postman_js_resend_label', __( 'Resend', 'post-smtp' ) ); } /** @@ -349,13 +349,15 @@ class PostmanEmailLogController { </div> <h2><?php /* Translators where (%s) is the name of the plugin */ - echo sprintf( __( '%s Email Log', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) )?></h2> + echo sprintf( __( '%s Email Log', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) )?></h2> + + <?php include_once POST_PATH . '/Postman/extra/donation.php'; ?> <div style="background: #ECECEC; border: 1px solid #CCC; padding: 0 10px; margin-top: 5px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;"> <p><?php - echo __( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.', Postman::TEXT_DOMAIN )?></p> + echo __( 'This is a record of deliveries made to the mail server. It does not neccessarily indicate sucessful delivery to the recipient.', 'post-smtp' )?></p> </div> <?php @@ -369,19 +371,19 @@ class PostmanEmailLogController { <form id="postman-email-log-filter" method="post"> <div id="email-log-filter" class="postman-log-row"> <div class="form-control"> - <label for="from_date"><?php _e( 'From Date', Postman::TEXT_DOMAIN ); ?></label> - <input id="from_date" class="email-log-date" value="<?php echo $from_date; ?>" type="text" name="from_date" placeholder="<?php _e( 'From Date', Postman::TEXT_DOMAIN ); ?>"> + <label for="from_date"><?php _e( 'From Date', 'post-smtp' ); ?></label> + <input id="from_date" class="email-log-date" value="<?php echo $from_date; ?>" type="text" name="from_date" placeholder="<?php _e( 'From Date', 'post-smtp' ); ?>"> </div> <div class="form-control"> - <label for="to_date"><?php _e( 'To Date', Postman::TEXT_DOMAIN ); ?></label> - <input id="to_date" class="email-log-date" value="<?php echo $to_date; ?>" type="text" name="to_date" placeholder="<?php _e( 'To Date', Postman::TEXT_DOMAIN ); ?>"> + <label for="to_date"><?php _e( 'To Date', 'post-smtp' ); ?></label> + <input id="to_date" class="email-log-date" value="<?php echo $to_date; ?>" type="text" name="to_date" placeholder="<?php _e( 'To Date', 'post-smtp' ); ?>"> </div> <div class="form-control"> - <label for="search"><?php _e( 'Search', Postman::TEXT_DOMAIN ); ?></label> - <input id="search" type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php _e( 'Search', Postman::TEXT_DOMAIN ); ?>"> + <label for="search"><?php _e( 'Search', 'post-smtp' ); ?></label> + <input id="search" type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php _e( 'Search', 'post-smtp' ); ?>"> </div> <div class="form-control"> - <label id="postman_page_records"><?php _e( 'Records per page', Postman::TEXT_DOMAIN ); ?></label> + <label id="postman_page_records"><?php _e( 'Records per page', 'post-smtp' ); ?></label> <select id="postman_page_records" name="postman_page_records"> <?php foreach ( $page_records as $value ) { @@ -392,10 +394,10 @@ class PostmanEmailLogController { </select> </div> <div class="form-control" style="padding: 0 5px 0 5px;"> - <button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter/Search', Postman::TEXT_DOMAIN ); ?></button> + <button type="submit" name="filter" class="button button-primary"><?php _e( 'Filter/Search', 'post-smtp' ); ?></button> </div> <div class="form-control"> - <button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', Postman::TEXT_DOMAIN ); ?></button> + <button type="submit" id="postman_trash_all" name="postman_trash_all" class="button button-primary"><?php _e( 'Trash All', 'post-smtp' ); ?></button> </div> </div> <div class="error">Please notice: when you select a date for example 11/20/2017, behind the scene the query select <b>11/20/2017 00:00:00</b>.<br>So if you searching for an email arrived that day at any hour you need to select 11/20/2017 as the <b>From Date</b> and 11/21/2017 as the <b>To Date</b>.</div> diff --git a/Postman/Postman-Email-Log/PostmanEmailLogPostType.php b/Postman/Postman-Email-Log/PostmanEmailLogPostType.php index d45f92d..38ab1d0 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogPostType.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogPostType.php @@ -34,8 +34,8 @@ if (! class_exists ( 'PostmanEmailLogPostType' )) { public static function create_post_type() { register_post_type ( self::POSTMAN_CUSTOM_POST_TYPE_SLUG, array ( 'labels' => array ( - 'name' => _x ( 'Sent Emails', 'The group of Emails that have been delivered', Postman::TEXT_DOMAIN ), - 'singular_name' => _x ( 'Sent Email', 'An Email that has been delivered', Postman::TEXT_DOMAIN ) + 'name' => _x ( 'Sent Emails', 'The group of Emails that have been delivered', 'post-smtp' ), + 'singular_name' => _x ( 'Sent Email', 'An Email that has been delivered', 'post-smtp' ) ), 'capability_type' => '', 'capabilities' => array () diff --git a/Postman/Postman-Email-Log/PostmanEmailLogService.php b/Postman/Postman-Email-Log/PostmanEmailLogService.php index dd51974..b1b1dff 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogService.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogService.php @@ -67,7 +67,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { * Logs successful email attempts * * @param PostmanMessage $message - * @param unknown $transcript + * @param mixed $transcript * @param PostmanModuleTransport $transport */ public function writeSuccessLog( PostmanEmailLog $log, PostmanMessage $message, $transcript, PostmanModuleTransport $transport ) { @@ -76,7 +76,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { $status = true; $subject = $message->getSubject(); if ( empty( $subject ) ) { - $statusMessage = sprintf( '%s: %s', __( 'Warning', Postman::TEXT_DOMAIN ), __( 'An empty subject line can result in delivery failure.', Postman::TEXT_DOMAIN ) ); + $statusMessage = sprintf( '%s: %s', __( 'Warning', 'post-smtp' ), __( 'An empty subject line can result in delivery failure.', 'post-smtp' ) ); $status = 'WARN'; } $this->createLog( $log, $message, $transcript, $statusMessage, $status, $transport ); @@ -88,13 +88,13 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { * Logs failed email attempts, requires more metadata so the email can be resent in the future * * @param PostmanMessage $message - * @param unknown $transcript + * @param mixed $transcript * @param PostmanModuleTransport $transport - * @param unknown $statusMessage - * @param unknown $originalTo - * @param unknown $originalSubject - * @param unknown $originalMessage - * @param unknown $originalHeaders + * @param mixed $statusMessage + * @param mixed $originalTo + * @param mixed $originalSubject + * @param mixed $originalMessage + * @param mixed $originalHeaders */ public function writeFailureLog( PostmanEmailLog $log, PostmanMessage $message = null, $transcript, PostmanModuleTransport $transport, $statusMessage ) { if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) { @@ -182,9 +182,9 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { } private function checkForLogErrors( PostmanEmailLog $log, $postMessage ) { - $message = __( 'You getting this message because an error detected while delivered your email.', Postman::TEXT_DOMAIN ); - $message .= "\r\n" . sprintf( __( 'For the domain: %1$s',Postman::TEXT_DOMAIN ), get_bloginfo('url') ); - $message .= "\r\n" . __( 'The log to paste when you open a support issue:', Postman::TEXT_DOMAIN ) . "\r\n"; + $message = __( 'You getting this message because an error detected while delivered your email.', 'post-smtp' ); + $message .= "\r\n" . sprintf( __( 'For the domain: %1$s','post-smtp' ), get_bloginfo('url') ); + $message .= "\r\n" . __( 'The log to paste when you open a support issue:', 'post-smtp' ) . "\r\n"; if ( $log->statusMessage && ! empty( $log->statusMessage ) ) { require_once POST_PATH . '/Postman/notifications/PostmanNotify.php'; @@ -227,9 +227,9 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { * Creates a Log object for use by writeToEmailLog() * * @param PostmanMessage $message - * @param unknown $transcript - * @param unknown $statusMessage - * @param unknown $success + * @param mixed $transcript + * @param mixed $statusMessage + * @param mixed $success * @param PostmanModuleTransport $transport * @return PostmanEmailLog */ @@ -263,7 +263,7 @@ if ( ! class_exists( 'PostmanEmailLogService' ) ) { $count = 0; foreach ( $addresses as $address ) { if ( $count >= 3 ) { - $flat .= sprintf( __( '.. +%d more', Postman::TEXT_DOMAIN ), sizeof( $addresses ) - $count ); + $flat .= sprintf( __( '.. +%d more', 'post-smtp' ), sizeof( $addresses ) - $count ); break; } if ( $count > 0 ) { @@ -284,7 +284,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) { /** * - * @return unknown + * @return mixed */ function __construct( $args = array() ) { $this->logger = new PostmanLogger( get_class( $this ) ); @@ -313,7 +313,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) { /** * * @param array $posts - * @param unknown $postid + * @param mixed $postid */ function verifyLogItemExistsAndRemove( $postid ) { $force_delete = true; @@ -336,7 +336,7 @@ if ( ! class_exists( 'PostmanEmailLogPurger' ) ) { /** * - * @param unknown $size + * @param mixed $size */ function truncateLogItems( $size ) { $index = count( $this->posts ); diff --git a/Postman/Postman-Email-Log/PostmanEmailLogView.php b/Postman/Postman-Email-Log/PostmanEmailLogView.php index 2db03d7..a9722bd 100644 --- a/Postman/Postman-Email-Log/PostmanEmailLogView.php +++ b/Postman/Postman-Email-Log/PostmanEmailLogView.php @@ -1,5 +1,7 @@ <?php +require_once dirname(__DIR__) . '/PostmanEmailLogs.php'; + /** * See http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/ */ @@ -92,25 +94,25 @@ class PostmanEmailLogView extends WP_List_Table { $transcriptUrl = admin_url( sprintf( $iframeUri, 'transcript', $item ['ID'] ) ); $resendUrl = admin_url( sprintf( $iframeUri, 'resend', $item ['ID'] ) ); - $meta_values = get_post_meta( $item ['ID'] ); + $meta_values = PostmanEmailLogs::get_data( $item ['ID'] ); $actions = array( - 'delete' => sprintf( '<a href="%s">%s</a>', $deleteUrl, _x( 'Delete', 'Delete an item from the email log', Postman::TEXT_DOMAIN ) ), - 'view' => sprintf( '<a href="%s" class="thickbox">%s</a>', $viewUrl, _x( 'View', 'View an item from the email log', Postman::TEXT_DOMAIN ) ), + 'delete' => sprintf( '<a href="%s">%s</a>', $deleteUrl, _x( 'Delete', 'Delete an item from the email log', 'post-smtp' ) ), + 'view' => sprintf( '<a href="%s" class="thickbox">%s</a>', $viewUrl, _x( 'View', 'View an item from the email log', 'post-smtp' ) ), ); if ( ! empty( $meta_values ['session_transcript'] [0] ) ) { - $actions ['transcript'] = sprintf( '<a href="%1$s" class="thickbox">%2$s</a>', $transcriptUrl, __( 'Session Transcript', Postman::TEXT_DOMAIN ) ); + $actions ['transcript'] = sprintf( '<a href="%1$s" class="thickbox">%2$s</a>', $transcriptUrl, __( 'Session Transcript', 'post-smtp' ) ); } else { - $actions ['transcript'] = sprintf( '%2$s', $transcriptUrl, __( 'Session Transcript', Postman::TEXT_DOMAIN ) ); + $actions ['transcript'] = sprintf( '%2$s', $transcriptUrl, __( 'Session Transcript', 'post-smtp' ) ); } if ( ! (empty( $meta_values ['original_to'] [0] ) && empty( $meta_values ['originalHeaders'] [0] )) ) { - // $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend', Postman::TEXT_DOMAIN ) ); + // $actions ['resend'] = sprintf ( '<a href="%s">%s</a>', $resendUrl, __ ( 'Resend', 'post-smtp' ) ); $emails = maybe_unserialize( $meta_values ['original_to'] [0] ); $to = is_array( $emails ) ? implode( ',', $emails ) : $emails; - $actions ['resend'] = sprintf( '<span id="%3$s"><a class="postman-open-resend" href="#">%2$s</a></span><div style="display:none;"><input type="hidden" name="security" value="%6$s"><input type="text" name="mail_to" class="regular-text ltr" data-id="%1$s" value="%4$s"><button class="postman-resend button button-primary">%2$s</button><i style="color: black;">%5$s</i></div>', $item ['ID'], __( 'Resend', Postman::TEXT_DOMAIN ), 'resend-' . $item ['ID'], esc_attr( $to ), __( 'comma-separated for multiple emails', Postman::TEXT_DOMAIN ), wp_create_nonce( 'resend' ) ); + $actions ['resend'] = sprintf( '<span id="%3$s"><a class="postman-open-resend" href="#">%2$s</a></span><div style="display:none;"><input type="hidden" name="security" value="%6$s"><input type="text" name="mail_to" class="regular-text ltr" data-id="%1$s" value="%4$s"><button class="postman-resend button button-primary">%2$s</button><i style="color: black;">%5$s</i></div>', $item ['ID'], __( 'Resend', 'post-smtp' ), 'resend-' . $item ['ID'], esc_attr( $to ), __( 'comma-separated for multiple emails', 'post-smtp' ), wp_create_nonce( 'resend' ) ); } else { - $actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', Postman::TEXT_DOMAIN ) ); + $actions ['resend'] = sprintf( '%2$s', $resendUrl, __( 'Resend', 'post-smtp' ) ); } // Return the title contents @@ -159,10 +161,10 @@ class PostmanEmailLogView extends WP_List_Table { function get_columns() { $columns = array( 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text - 'title' => _x( 'Subject', 'What is the subject of this message?', Postman::TEXT_DOMAIN ), - 'sent_to' => __( 'Sent To', Postman::TEXT_DOMAIN ), - 'status' => __( 'Status', Postman::TEXT_DOMAIN ), - 'date' => _x( 'Delivery Time', 'When was this email sent?', Postman::TEXT_DOMAIN ), + 'title' => _x( 'Subject', 'What is the subject of this message?', 'post-smtp' ), + 'sent_to' => __( 'Sent To', 'post-smtp' ), + 'status' => __( 'Status', 'post-smtp' ), + 'date' => _x( 'Delivery Time', 'When was this email sent?', 'post-smtp' ), ); return $columns; } @@ -222,7 +224,7 @@ class PostmanEmailLogView extends WP_List_Table { */ function get_bulk_actions() { $actions = array( - 'bulk_delete' => _x( 'Delete', 'Delete an item from the email log', Postman::TEXT_DOMAIN ), + 'bulk_delete' => _x( 'Delete', 'Delete an item from the email log', 'post-smtp' ), ); return $actions; } @@ -363,16 +365,16 @@ class PostmanEmailLogView extends WP_List_Table { // if this PHP system support humanTime, than use it if ( ! empty( $humanTime ) ) { /* Translators: where %s indicates the relative time from now */ - $date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', Postman::TEXT_DOMAIN ), $humanTime ); + $date = sprintf( _x( '%s ago', 'A relative time as in "five days ago"', 'post-smtp' ), $humanTime ); } - $meta_values = get_post_meta( $post->ID ); + $meta_values = PostmanEmailLogs::get_data( $post->ID ); $sent_to = array_map( 'sanitize_email', explode( ',' , $meta_values ['to_header'] [0] ) ); $flattenedPost = array( // the post title must be escaped as they are displayed in the HTML output 'sent_to' => implode( ', ', $sent_to ), 'title' => esc_html( $post->post_title ), // the post status must be escaped as they are displayed in the HTML output - 'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', Postman::TEXT_DOMAIN )), + 'status' => ($post->post_excerpt != null ? esc_html( $post->post_excerpt ) : __( 'Sent', 'post-smtp' )), 'date' => date( "$date_format $time_format", strtotime( $post->post_date ) ), 'ID' => $post->ID, ); diff --git a/Postman/Postman-Mail/PostmanDefaultModuleTransport.php b/Postman/Postman-Mail/PostmanDefaultModuleTransport.php index 8f30962..3234a26 100644 --- a/Postman/Postman-Mail/PostmanDefaultModuleTransport.php +++ b/Postman/Postman-Mail/PostmanDefaultModuleTransport.php @@ -8,7 +8,7 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) { /** * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct($rootPluginFilenameAndPath) { parent::__construct ( $rootPluginFilenameAndPath ); @@ -102,7 +102,7 @@ if (! class_exists ( 'PostmanSmtpModuleTransport' )) { return self::SLUG; } public function getName() { - return __ ( 'Default', Postman::TEXT_DOMAIN ); + return __ ( 'Default', 'post-smtp' ); } public function getHostname() { return 'localhost'; diff --git a/Postman/Postman-Mail/PostmanEmailAddress.php b/Postman/Postman-Mail/PostmanEmailAddress.php index 67c4662..123064d 100644 --- a/Postman/Postman-Mail/PostmanEmailAddress.php +++ b/Postman/Postman-Mail/PostmanEmailAddress.php @@ -61,8 +61,8 @@ if (! class_exists ( 'PostmanEmailAddress' )) { /** * Accept a String of addresses or an array and return an array * - * @param unknown $recipientList - * @param unknown $recipients + * @param mixed $recipientList + * @param mixed $recipients */ public static function convertToArray($emails) { assert ( ! empty ( $emails ) ); diff --git a/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php b/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php index ab568ea..98fc1f1 100644 --- a/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php +++ b/Postman/Postman-Mail/PostmanGmailApiModuleTransport.php @@ -98,7 +98,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport return self::SLUG; } public function getName() { - return __ ( 'Gmail API', Postman::TEXT_DOMAIN ); + return __ ( 'Gmail API', 'post-smtp' ); } public function isEnvelopeFromValidationSupported() { return false; @@ -148,7 +148,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport */ public function getDeliveryDetails() { /* translators: where (1) is the secure icon and (2) is the transport name */ - return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', Postman::TEXT_DOMAIN ), '🔐', $this->getName () ); + return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () ); } /** @@ -162,7 +162,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport $this->setReadyForOAuthGrant (); if ($this->isPermissionNeeded ()) { /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */ - $message = sprintf ( __ ( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', Postman::TEXT_DOMAIN ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () ); + $message = sprintf ( __ ( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'post-smtp' ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () ); $message .= sprintf ( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl (), $this->getScribe ()->getRequestPermissionLinkText () ); array_push ( $messages, $message ); $this->setNotConfiguredAndReady (); @@ -189,7 +189,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport * * 70 gmail api on port 465 to www.googleapis.com * - * @param unknown $hostData + * @param mixed $hostData */ public function getConfigurationBid(PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer) { $recommendation = array (); @@ -217,7 +217,7 @@ class PostmanGmailApiModuleTransport extends PostmanAbstractZendModuleTransport $overrideItem ['auth_items'] = array ( array ( 'selected' => true, - 'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', 'post-smtp' ), 'value' => 'oauth2' ) ); diff --git a/Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php b/Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php index 3cb05c9..544d5fb 100644 --- a/Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php +++ b/Postman/Postman-Mail/PostmanGmailApiModuleZendMailTransport.php @@ -112,7 +112,7 @@ if (! class_exists ( 'PostmanGmailApiModuleZendMailTransport' )) { * * @param string $host * OPTIONAL (Default: 127.0.0.1) - * @param array|null $config + * @param array $config * OPTIONAL (Default: null) * @return void * @@ -165,7 +165,7 @@ if (! class_exists ( 'PostmanGmailApiModuleZendMailTransport' )) { /** * Gets the connection protocol instance * - * @return Postman_Zend_Mail_Protocol|null + * @return Postman_Zend_Mail_Protocol_Abstract|null */ public function getConnection() { return $this->_connection; diff --git a/Postman/Postman-Mail/PostmanMailgunMailEngine.php b/Postman/Postman-Mail/PostmanMailgunMailEngine.php index f098ec9..abb0466 100644 --- a/Postman/Postman-Mail/PostmanMailgunMailEngine.php +++ b/Postman/Postman-Mail/PostmanMailgunMailEngine.php @@ -27,8 +27,8 @@ if ( ! class_exists( 'PostmanMailgunMailEngine' ) ) { /** * - * @param unknown $senderEmail - * @param unknown $accessToken + * @param mixed $senderEmail + * @param mixed $accessToken */ function __construct( $apiKey, $domainName ) { assert( ! empty( $apiKey ) ); diff --git a/Postman/Postman-Mail/PostmanMailgunTransport.php b/Postman/Postman-Mail/PostmanMailgunTransport.php index dcbc1ae..a673e01 100644 --- a/Postman/Postman-Mail/PostmanMailgunTransport.php +++ b/Postman/Postman-Mail/PostmanMailgunTransport.php @@ -16,7 +16,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements /** * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct( $rootPluginFilenameAndPath ) { parent::__construct( $rootPluginFilenameAndPath ); @@ -36,7 +36,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements return self::SLUG; } public function getName() { - return __( 'Mailgun API', Postman::TEXT_DOMAIN ); + return __( 'Mailgun API', 'post-smtp' ); } /** * v0.2.1 @@ -49,7 +49,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements /** * v0.2.1 * - * @return string + * @return int */ public function getPort() { return self::PORT; @@ -78,12 +78,12 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements } public function getDeliveryDetails() { /* translators: where (1) is the secure icon and (2) is the transport name */ - return sprintf( __( 'Post SMTP will send mail via the <b>%1$s %2$s</b>.', Postman::TEXT_DOMAIN ), '🔐', $this->getName() ); + return sprintf( __( 'Post SMTP will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName() ); } /** * - * @param unknown $data + * @param mixed $data */ public function prepareOptionsForExport( $data ) { $data = parent::prepareOptionsForExport( $data ); @@ -102,17 +102,17 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements $domainName = $this->options->getMailgunDomainName(); if ( empty( $apiKey ) ) { - array_push( $messages, __( 'API Key can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push( $messages, __( 'API Key can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady(); } if ( empty( $domainName ) ) { - array_push( $messages, __( 'Domain Name can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push( $messages, __( 'Domain Name can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady(); } if ( ! $this->isSenderConfigured() ) { - array_push( $messages, __( 'Message From Address can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push( $messages, __( 'Message From Address can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady(); } return $messages; @@ -139,8 +139,8 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements /** * - * @param unknown $hostname - * @param unknown $response + * @param mixed $hostname + * @param mixed $response */ public function populateConfiguration( $hostname ) { $response = parent::populateConfiguration( $hostname ); @@ -155,7 +155,7 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements $overrideItem ['auth_items'] = array( array( 'selected' => true, - 'name' => __( 'API Key', Postman::TEXT_DOMAIN ), + 'name' => __( 'API Key', 'post-smtp' ), 'value' => 'api_key', ), ); @@ -184,40 +184,40 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements */ public function addSettings() { // the Mailgun Auth section - add_settings_section( PostmanMailgunTransport::MAILGUN_AUTH_SECTION, __( 'Authentication', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanMailgunTransport::MAILGUN_AUTH_SECTION, __( 'Authentication', 'post-smtp' ), array( $this, 'printMailgunAuthSectionInfo', ), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS ); - add_settings_field( PostmanOptions::MAILGUN_API_KEY, __( 'API Key', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::MAILGUN_API_KEY, __( 'API Key', 'post-smtp' ), array( $this, 'mailgun_api_key_callback', ), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION ); - add_settings_field( PostmanOptions::MAILGUN_DOMAIN_NAME, __( 'Domain Name', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::MAILGUN_DOMAIN_NAME, __( 'Domain Name', 'post-smtp' ), array( $this, 'mailgun_domain_name_callback', ), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION ); - add_settings_field( PostmanOptions::MAILGUN_REGION, __( 'Mailgun Europe Region?', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::MAILGUN_REGION, __( 'Mailgun Europe Region?', 'post-smtp' ), array( $this, 'mailgun_region_callback', ), PostmanMailgunTransport::MAILGUN_AUTH_OPTIONS, PostmanMailgunTransport::MAILGUN_AUTH_SECTION ); } public function printMailgunAuthSectionInfo() { /* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */ - printf( '<p id="wizard_mailgun_auth_help">%s</p>', sprintf( __( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://mailgun.com', 'mailgun.com', 'https://app.mailgun.com/app/domains/' ) ); + printf( '<p id="wizard_mailgun_auth_help">%s</p>', sprintf( __( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://mailgun.com', 'mailgun.com', 'https://app.mailgun.com/app/domains/' ) ); } /** */ public function mailgun_api_key_callback() { - printf( '<input type="password" autocomplete="off" id="mailgun_api_key" name="postman_options[mailgun_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunApiKey() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getMailgunApiKey() ) ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="password" autocomplete="off" id="mailgun_api_key" name="postman_options[mailgun_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunApiKey() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getMailgunApiKey() ) ) : '', __( 'Required', 'post-smtp' ) ); print '<input type="button" id="toggleMailgunApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />'; } function mailgun_domain_name_callback() { - printf( '<input type="text" autocomplete="off" id="mailgun_domain_name" name="postman_options[mailgun_domain_name]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunDomainName() ? esc_attr( $this->options->getMailgunDomainName() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" autocomplete="off" id="mailgun_domain_name" name="postman_options[mailgun_domain_name]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMailgunDomainName() ? esc_attr( $this->options->getMailgunDomainName() ) : '', __( 'Required', 'post-smtp' ) ); } function mailgun_region_callback() { @@ -248,14 +248,14 @@ class PostmanMailgunTransport extends PostmanAbstractModuleTransport implements public function printWizardAuthenticationStep() { print '<section class="wizard_mailgun">'; $this->printMailgunAuthSectionInfo(); - printf( '<label for="api_key">%s</label>', __( 'API Key', Postman::TEXT_DOMAIN ) ); + printf( '<label for="api_key">%s</label>', __( 'API Key', 'post-smtp' ) ); print '<br />'; print $this->mailgun_api_key_callback(); - printf( '<label for="domain_name">%s</label>', __( 'Domain Name', Postman::TEXT_DOMAIN ) ); + printf( '<label for="domain_name">%s</label>', __( 'Domain Name', 'post-smtp' ) ); print '<br />'; print $this->mailgun_domain_name_callback(); print '<br />'; - printf( '<label for="mailgun_region">%s</label>', __( 'Mailgun Europe Region?', Postman::TEXT_DOMAIN ) ); + printf( '<label for="mailgun_region">%s</label>', __( 'Mailgun Europe Region?', 'post-smtp' ) ); print '<br />'; print $this->mailgun_region_callback(); print '</section>'; diff --git a/Postman/Postman-Mail/PostmanMandrillMailEngine.php b/Postman/Postman-Mail/PostmanMandrillMailEngine.php index 7549a37..6ecc156 100644 --- a/Postman/Postman-Mail/PostmanMandrillMailEngine.php +++ b/Postman/Postman-Mail/PostmanMandrillMailEngine.php @@ -22,8 +22,8 @@ if ( ! class_exists( 'PostmanMandrillMailEngine' ) ) { /** * - * @param unknown $senderEmail - * @param unknown $accessToken + * @param mixed $senderEmail + * @param mixed $accessToken */ function __construct( $apiKey ) { assert( ! empty( $apiKey ) ); diff --git a/Postman/Postman-Mail/PostmanMandrillTransport.php b/Postman/Postman-Mail/PostmanMandrillTransport.php index 795abfd..8284660 100644 --- a/Postman/Postman-Mail/PostmanMandrillTransport.php +++ b/Postman/Postman-Mail/PostmanMandrillTransport.php @@ -25,7 +25,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements /** * - * @param unknown $data + * @param mixed $data */ public function prepareOptionsForExport($data) { $data = parent::prepareOptionsForExport ( $data ); @@ -41,7 +41,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements return self::SLUG; } public function getName() { - return __ ( 'Mandrill API', Postman::TEXT_DOMAIN ); + return __ ( 'Mandrill API', 'post-smtp' ); } /** * v0.2.1 @@ -54,7 +54,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements /** * v0.2.1 * - * @return string + * @return int */ public function getPort() { return self::PORT; @@ -132,7 +132,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements */ public function getDeliveryDetails() { /* translators: where (1) is the secure icon and (2) is the transport name */ - return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', Postman::TEXT_DOMAIN ), '🔐', $this->getName () ); + return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () ); } /** @@ -144,11 +144,11 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements $messages = parent::validateTransportConfiguration (); $apiKey = $this->options->getMandrillApiKey (); if (empty ( $apiKey )) { - array_push ( $messages, __ ( 'API Key can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push ( $messages, __ ( 'API Key can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady (); } if (! $this->isSenderConfigured ()) { - array_push ( $messages, __ ( 'Message From Address can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady (); } return $messages; @@ -191,7 +191,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements $overrideItem ['auth_items'] = array ( array ( 'selected' => true, - 'name' => __ ( 'API Key', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'API Key', 'post-smtp' ), 'value' => 'api_key' ) ); @@ -220,12 +220,12 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements */ public function addSettings() { // the Mandrill Auth section - add_settings_section ( PostmanMandrillTransport::MANDRILL_AUTH_SECTION, __ ( 'Authentication', Postman::TEXT_DOMAIN ), array ( + add_settings_section ( PostmanMandrillTransport::MANDRILL_AUTH_SECTION, __ ( 'Authentication', 'post-smtp' ), array ( $this, 'printMandrillAuthSectionInfo' ), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS ); - add_settings_field ( PostmanOptions::MANDRILL_API_KEY, __ ( 'API Key', Postman::TEXT_DOMAIN ), array ( + add_settings_field ( PostmanOptions::MANDRILL_API_KEY, __ ( 'API Key', 'post-smtp' ), array ( $this, 'mandrill_api_key_callback' ), PostmanMandrillTransport::MANDRILL_AUTH_OPTIONS, PostmanMandrillTransport::MANDRILL_AUTH_SECTION ); @@ -235,13 +235,13 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements */ public function printMandrillAuthSectionInfo() { /* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */ - printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://mandrillapp.com', 'Mandrillapp.com', 'https://mandrillapp.com/settings' ) ); + printf ( '<p id="wizard_mandrill_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://mandrillapp.com', 'Mandrillapp.com', 'https://mandrillapp.com/settings' ) ); } /** */ public function mandrill_api_key_callback() { - printf ( '<input type="password" autocomplete="off" id="mandrill_api_key" name="postman_options[mandrill_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMandrillApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getMandrillApiKey () ) ) : '', __ ( 'Required', Postman::TEXT_DOMAIN ) ); + printf ( '<input type="password" autocomplete="off" id="mandrill_api_key" name="postman_options[mandrill_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getMandrillApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getMandrillApiKey () ) ) : '', __ ( 'Required', 'post-smtp' ) ); print ' <input type="button" id="toggleMandrillApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />'; } @@ -268,7 +268,7 @@ class PostmanMandrillTransport extends PostmanAbstractModuleTransport implements public function printWizardAuthenticationStep() { print '<section class="wizard_mandrill">'; $this->printMandrillAuthSectionInfo (); - printf ( '<label for="api_key">%s</label>', __ ( 'API Key', Postman::TEXT_DOMAIN ) ); + printf ( '<label for="api_key">%s</label>', __ ( 'API Key', 'post-smtp' ) ); print '<br />'; print $this->mandrill_api_key_callback (); print '</section>'; diff --git a/Postman/Postman-Mail/PostmanMessage.php b/Postman/Postman-Mail/PostmanMessage.php index 2af67ef..7f8949e 100644 --- a/Postman/Postman-Mail/PostmanMessage.php +++ b/Postman/Postman-Mail/PostmanMessage.php @@ -52,7 +52,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { } function __get( $name ) { - $message = __( '<code>%1$s</code> property of a <code>PostmanMessage</code> object is <strong>not supported</strong>. For now all of this class properties are private.', Postman::TEXT_DOMAIN ); + $message = __( '<code>%1$s</code> property of a <code>PostmanMessage</code> object is <strong>not supported</strong>. For now all of this class properties are private.', 'post-smtp' ); if ( WP_DEBUG ) { trigger_error( sprintf( $message, $name ) ); @@ -63,7 +63,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { $class = new ReflectionClass(__CLASS__); $methods = $class->getMethods(ReflectionMethod::IS_PUBLIC ); - $message = __( '<code>%1$s</code> method of a <code>PostmanMessage</code> object is <strong>not supported</strong>. Use one of the following methods <pre><code>%2$s</code></pre>', Postman::TEXT_DOMAIN ); + $message = __( '<code>%1$s</code> method of a <code>PostmanMessage</code> object is <strong>not supported</strong>. Use one of the following methods <pre><code>%2$s</code></pre>', 'post-smtp' ); if ( WP_DEBUG ) { trigger_error( sprintf( $message, $name, print_r( $methods, true ) ) ); @@ -291,7 +291,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { /** * Set the charset * - * @param unknown $charset + * @param mixed $charset */ public function setCharset( $charset ) { $this->charset = $charset; @@ -310,7 +310,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { } /** * - * @param unknown $recipients + * @param mixed $recipients * Array or comma-separated list of email addresses to send message. * @throws Exception */ @@ -319,7 +319,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { } /** * - * @param unknown $recipients + * @param mixed $recipients * Array or comma-separated list of email addresses to send message. * @throws Exception */ @@ -328,7 +328,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { } /** * - * @param unknown $recipients + * @param mixed $recipients * Array or comma-separated list of email addresses to send message. * @throws Exception */ @@ -337,7 +337,7 @@ if ( ! class_exists( 'PostmanMessage' ) ) { } /** * - * @param unknown $recipients + * @param mixed $recipients * Array or comma-separated list of email addresses to send message. * @throws Exception */ @@ -391,8 +391,8 @@ if ( ! class_exists( 'PostmanMessage' ) ) { * Add the headers that were processed in processHeaders() * Zend requires that several headers are specially handled. * - * @param unknown $name - * @param unknown $value + * @param mixed $name + * @param mixed $value * @param Postman_Zend_Mail $mail */ private function processHeader( $name, $content ) { @@ -477,9 +477,9 @@ if ( ! class_exists( 'PostmanMessage' ) ) { /** * - * @param unknown $desc - * @param unknown $name - * @param unknown $content + * @param mixed $desc + * @param mixed $name + * @param mixed $content */ private function logProcessHeader( $desc, $name, $content ) { $this->logger->debug( 'Processing ' . $desc . ' Header - ' . $name . ': ' . $content ); diff --git a/Postman/Postman-Mail/PostmanModuleTransport.php b/Postman/Postman-Mail/PostmanModuleTransport.php index 21c1624..37d692d 100644 --- a/Postman/Postman-Mail/PostmanModuleTransport.php +++ b/Postman/Postman-Mail/PostmanModuleTransport.php @@ -43,6 +43,7 @@ interface PostmanModuleTransport extends PostmanTransport { public function isReadyToSendMail(); public function getFromEmailAddress(); public function getFromName(); + public function getHostname(); public function getProtocol(); public function isEmailValidationSupported(); public function getPort(); @@ -68,7 +69,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport /** * These internal variables are exposed for the subclasses to use * - * @var unknown + * @var mixed */ protected $logger; protected $options; @@ -124,7 +125,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport /** * - * @param unknown $data + * @param mixed $data */ public function prepareOptionsForExport($data) { // no-op @@ -139,7 +140,7 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport /** * - * @param unknown $queryHostname + * @param mixed $queryHostname */ protected function createScribe($hostname) { $scribe = new PostmanNonOAuthScribe ( $hostname ); @@ -281,8 +282,8 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport /** * - * @param unknown $hostname - * @param unknown $response + * @param mixed $hostname + * @param mixed $response */ public function populateConfiguration($hostname) { $configuration = array (); @@ -290,8 +291,8 @@ abstract class PostmanAbstractModuleTransport implements PostmanModuleTransport } /** * - * @param unknown $winningRecommendation - * @param unknown $response + * @param mixed $winningRecommendation + * @param mixed $response */ public function populateConfigurationFromRecommendation($winningRecommendation) { $configuration = array (); @@ -421,7 +422,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT /** * - * @param unknown $data + * @param mixed $data */ public function prepareOptionsForExport($data) { $data = parent::prepareOptionsForExport ( $data ); @@ -455,7 +456,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT /** * - * @param unknown $queryHostname + * @param mixed $queryHostname */ protected function createScribe($hostname) { $scribe = null; @@ -502,13 +503,18 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT $deliveryDetails ['transport_name'] = $this->getTransportDescription ( $this->getSecurityType () ); $deliveryDetails ['host'] = $this->getHostname () . ':' . $this->getPort (); $deliveryDetails ['auth_desc'] = $this->getAuthenticationDescription ( $this->getAuthenticationType () ); + + if ( $deliveryDetails ['host'] == 'localhost:25' ) { + $deliveryDetails ['transport_name'] = __( 'Sendmail (server defualt - not SMTP)', 'post-smtp'); + } + /* translators: where (1) is the transport type, (2) is the host, and (3) is the Authentication Type (e.g. Postman will send mail via smtp.gmail.com:465 using OAuth 2.0 authentication.) */ - return sprintf ( __ ( 'Postman will send mail via %1$s to %2$s using %3$s authentication.', Postman::TEXT_DOMAIN ), '<b>' . $deliveryDetails ['transport_name'] . '</b>', '<b>' . $deliveryDetails ['host'] . '</b>', '<b>' . $deliveryDetails ['auth_desc'] . '</b>' ); + return sprintf ( __ ( 'Postman will send mail via %1$s to %2$s using %3$s authentication.', 'post-smtp' ), '<b>' . $deliveryDetails ['transport_name'] . '</b>', '<b>' . $deliveryDetails ['host'] . '</b>', '<b>' . $deliveryDetails ['auth_desc'] . '</b>' ); } /** * - * @param unknown $encType + * @param mixed $encType * @return string */ protected function getTransportDescription($encType) { @@ -525,13 +531,13 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT /** * - * @param unknown $authType + * @param mixed $authType */ protected function getAuthenticationDescription($authType) { if (PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 == $authType) { return 'OAuth 2.0'; } else if (PostmanOptions::AUTHENTICATION_TYPE_NONE == $authType) { - return _x ( 'no', 'as in "There is no Spoon"', Postman::TEXT_DOMAIN ); + return _x ( 'no', 'as in "There is no Spoon"', 'post-smtp' ); } else { switch ($authType) { case PostmanOptions::AUTHENTICATION_TYPE_CRAMMD5 : @@ -550,7 +556,7 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT $authDescription = $authType; break; } - return sprintf ( '%s (%s)', __ ( 'Password', Postman::TEXT_DOMAIN ), $authDescription ); + return sprintf ( '%s (%s)', __ ( 'Password', 'post-smtp' ), $authDescription ); } } @@ -575,13 +581,13 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT parent::validateTransportConfiguration (); $messages = parent::validateTransportConfiguration (); if (! $this->isSenderConfigured ()) { - array_push ( $messages, __ ( 'Message From Address can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady (); } if ($this->getAuthenticationType () == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2) { if (! $this->isOAuth2ClientIdAndClientSecretConfigured ()) { /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */ - array_push ( $messages, sprintf ( __ ( 'OAuth 2.0 authentication requires a %1$s and %2$s.', Postman::TEXT_DOMAIN ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () ) ); + array_push ( $messages, sprintf ( __ ( 'OAuth 2.0 authentication requires a %1$s and %2$s.', 'post-smtp' ), $this->getScribe ()->getClientIdLabel (), $this->getScribe ()->getClientSecretLabel () ) ); $this->setNotConfiguredAndReady (); } } @@ -621,8 +627,8 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT /** * - * @param unknown $hostname - * @param unknown $response + * @param mixed $hostname + * @param mixed $response */ public function populateConfiguration($hostname) { $response = parent::populateConfiguration ( $hostname ); @@ -650,8 +656,8 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT /** * Populate the Ajax response for the Setup Wizard / Manual Configuration * - * @param unknown $hostname - * @param unknown $response + * @param mixed $hostname + * @param mixed $response */ public function populateConfigurationFromRecommendation($winningRecommendation) { $response = parent::populateConfigurationFromRecommendation ( $winningRecommendation ); @@ -703,21 +709,21 @@ abstract class PostmanAbstractZendModuleTransport extends PostmanAbstractModuleT if ($socket->auth_crammd5 || $socket->auth_login || $socket->authPlain) { array_push ( $overrideAuthItems, array ( 'selected' => $passwordMode, - 'name' => __ ( 'Password (requires username and password)', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'Password (requires username and password)', 'post-smtp' ), 'value' => 'password' ) ); } if ($socket->auth_xoauth || $winningRecommendation ['auth'] == 'oauth2') { array_push ( $overrideAuthItems, array ( 'selected' => $oauth2Mode, - 'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'OAuth 2.0 (requires Client ID and Client Secret)', 'post-smtp' ), 'value' => 'oauth2' ) ); } if ($socket->auth_none) { array_push ( $overrideAuthItems, array ( 'selected' => $noAuthMode, - 'name' => __ ( 'None', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'None', 'post-smtp' ), 'value' => 'none' ) ); } diff --git a/Postman/Postman-Mail/PostmanMyMailConnector.php b/Postman/Postman-Mail/PostmanMyMailConnector.php index e08aa02..f6b7e54 100644 --- a/Postman/Postman-Mail/PostmanMyMailConnector.php +++ b/Postman/Postman-Mail/PostmanMyMailConnector.php @@ -155,7 +155,6 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) { * * @access public * @param mixed $message - * @return array */ public function reset() { update_option( '_transient__mailster_send_period_timeout', false ); @@ -169,10 +168,10 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) { * * @access public * @param mixed $delivery_methods - * @return void + * @return mixed */ public function delivery_method( $delivery_methods ) { - $delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP', Postman::TEXT_DOMAIN ); + $delivery_methods [ MAILSTER_POSTMAN_ID ] = __( 'Postman SMTP', 'post-smtp' ); return $delivery_methods; } @@ -196,7 +195,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) { */ public function activate() { if ( defined( 'MAILSTER_VERSION' ) && version_compare( MAILSTER_POSTMAN_REQUIRED_VERSION, MAILSTER_VERSION, '<=' ) ) { - mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); + mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', 'post-smtp' ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); $this->reset(); } } @@ -212,7 +211,7 @@ if ( ! class_exists( 'PostmanMyMailConnector' ) ) { if ( mailster_option( 'deliverymethod' ) == MAILSTER_POSTMAN_ID ) { mailster_update_option( 'deliverymethod', 'simple' ); /* Translators where %s is the name of the page */ - mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', Postman::TEXT_DOMAIN ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); + mailster_notice( sprintf( __( 'MyMail: Change the delivery method in the %s!', 'post-smtp' ), sprintf( '<a href="edit.php?post_type=newsletter&page=mailster_settings&mailster_remove_notice=mailster_delivery_method#delivery">%s</a>', __( 'Settings', 'postman-smtp' ) ) ), '', false, 'delivery_method' ); } } } diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index 32cfb9e..b3e13b9 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -22,8 +22,8 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { /** * - * @param unknown $senderEmail - * @param unknown $accessToken + * @param mixed $senderEmail + * @param mixed $accessToken */ function __construct( $apiKey ) { assert( ! empty( $apiKey ) ); @@ -41,86 +41,62 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { public function send( PostmanMessage $message ) { $options = PostmanOptions::getInstance(); - // add the From Header + $email = new \SendGrid\Mail\Mail(); + + // add the From Header $sender = $message->getFromAddress(); $senderEmail = ! empty( $sender->getEmail() ) ? $sender->getEmail() : $options->getMessageSenderEmail(); $senderName = ! empty( $sender->getName() ) ? $sender->getName() : $options->getMessageSenderName(); - $from = new SendGrid\Email( $senderName, $senderEmail ); + $email->setFrom($senderEmail, $senderName); - // now log it + // now log it $sender->log( $this->logger, 'From' ); - // add the to recipients - $counter = 0; - $emails = array(); - /** - * @todo: Find a better approch. - */ - $duplicates = array(); + // add the to recipients foreach ( ( array ) $message->getToRecipients() as $recipient ) { - $recipient->log( $this->logger, 'To' ); - - $email = $recipient->getEmail(); - if ( $counter == 0 ) { - $this->logger->debug( 'Adding to=' . $recipient->getEmail() ); - $to = new SendGrid\Email($recipient->getName(), $recipient->getEmail() ); - $duplicates[] = $email; - } else { - if ( ! in_array( $email, $duplicates ) ) { - $duplicates[] = $email; - $this->logger->debug( 'Adding personalization to=' . $recipient->getEmail() ); - $emails[] = new SendGrid\Email($recipient->getName(), $recipient->getEmail() ); - } - } - - $counter++; + $emails[] = new \SendGrid\Mail\To($recipient->getEmail(), $recipient->getName() ); } + $email->addTos( $emails ); + // add the subject if ( null !== $message->getSubject() ) { - $subject = $message->getSubject(); - } + $email->setSubject($message->getSubject()); + } // add the message content $textPart = $message->getBodyTextPart(); if ( ! empty( $textPart ) ) { $this->logger->debug( 'Adding body as text' ); - $content = new SendGrid\Content("text/plain", $textPart); - } + $email->addContent("text/plain", $textPart); + } $htmlPart = $message->getBodyHtmlPart(); if ( ! empty( $htmlPart ) ) { $this->logger->debug( 'Adding body as html' ); - $content = new SendGrid\Content("text/html", $htmlPart); - } - - $mail = new SendGrid\Mail($from, $subject, $to, $content); - - foreach ( $emails as $email) { - $mail->personalization[0]->addTo($email); + $email->addContent("text/html", $htmlPart); } // add the reply-to $replyTo = $message->getReplyTo(); // $replyTo is null or a PostmanEmailAddress object if ( isset( $replyTo ) ) { - $reply_to = new SendGrid\ReplyTo( $replyTo->getEmail(), $replyTo->getName() ); - $mail->setReplyTo($reply_to); + $email->setReplyTo( $replyTo->getEmail(), $replyTo->getName() ); } // add the Postman signature - append it to whatever the user may have set if ( ! $options->isStealthModeEnabled() ) { $pluginData = apply_filters( 'postman_get_plugin_metadata', null ); - $mail->personalization[0]->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) ); + $email->addHeader( 'X-Mailer', sprintf( 'Postman SMTP %s for WordPress (%s)', $pluginData ['version'], 'https://wordpress.org/plugins/post-smtp/' ) ); } // add the headers - see http://framework.zend.com/manual/1.12/en/zend.mail.additional-headers.html foreach ( ( array ) $message->getHeaders() as $header ) { $this->logger->debug( sprintf( 'Adding user header %s=%s', $header ['name'], $header ['content'] ) ); - $mail->personalization[0]->addHeader( $header ['name'], $header ['content'] ); + $email->addHeader( $header ['name'], $header ['content'] ); } // if the caller set a Content-Type header, use it @@ -130,28 +106,25 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { } // add the cc recipients + $ccEmails = array(); foreach ( ( array ) $message->getCcRecipients() as $recipient ) { - if ( ! in_array( $recipient->getEmail(), $duplicates ) ) { - $recipient->log( $this->logger, 'Cc' ); - $email = new SendGrid\Email( $recipient->getName(), $recipient->getEmail() ); - $mail->personalization[0]->addCc( $email ); - } - + $recipient->log( $this->logger, 'Cc' ); + $ccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() ); } + $email->addCcs($ccEmails); - // add the bcc recipients + // add the bcc recipients + $bccEmails = array(); foreach ( ( array ) $message->getBccRecipients() as $recipient ) { - if ( ! in_array( $recipient->getEmail(), $duplicates ) ) { - $recipient->log($this->logger, 'Bcc'); - $email = new SendGrid\Email($recipient->getName(), $recipient->getEmail()); - $mail->personalization[0]->addBcc($email); - } + $recipient->log($this->logger, 'Bcc'); + $bccEmails[] = new \SendGrid\Mail\Cc( $recipient->getEmail(), $recipient->getName() ); } + $email->addBccs($bccEmails); - // add the messageId + // add the messageId $messageId = $message->getMessageId(); if ( ! empty( $messageId ) ) { - $mail->personalization[0]->addHeader( 'message-id', $messageId ); + $email->addHeader( 'message-id', $messageId ); } // add attachments @@ -160,13 +133,13 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $attachments = $this->addAttachmentsToMail( $message ); foreach ( $attachments as $index => $attachment ) { - $attach = new SendGrid\Attachment(); - $attach->setContent($attachment['content']); - $attach->setType($attachment['type']); - $attach->setFilename($attachment['file_name']); - $attach->setDisposition("attachment"); - $attach->setContentId($attachment['id']); - $mail->addAttachment($attach); + + $email->addAttachment( + $attachment['content'], + $attachment['type'], + $attachment['file_name'], + "attachment" + ); } try { @@ -174,14 +147,14 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { if ( $this->logger->isDebug() ) { $this->logger->debug( 'Creating SendGrid service with apiKey=' . $this->apiKey ); } - $sendgrid = new SendGrid( $this->apiKey ); + $sendgrid = new \SendGrid( $this->apiKey ); // send the message if ( $this->logger->isDebug() ) { $this->logger->debug( 'Sending mail' ); } - $response = $sendgrid->client->mail()->send()->post($mail); + $response = $sendgrid->send($email); if ( $this->logger->isInfo() ) { $this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) ); } @@ -196,7 +169,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $e = ! $email_sent ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message; $this->transcript = $e; $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; - $this->transcript .= print_r( $mail, true ); + $this->transcript .= print_r( $email, true ); $this->logger->debug( 'Transcript=' . $this->transcript ); @@ -204,11 +177,11 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { } $this->transcript = print_r( $response->body(), true ); $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; - $this->transcript .= print_r( $mail, true ); + $this->transcript .= print_r( $email, true ); } catch ( SendGrid\Exception $e ) { $this->transcript = $e->getMessage(); $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; - $this->transcript .= print_r( $mail, true ); + $this->transcript .= print_r( $email, true ); $this->logger->debug( 'Transcript=' . $this->transcript ); throw $e; @@ -219,22 +192,22 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { private function errorCodesMap($error_code) { switch ($error_code) { case 413: - $message = sprintf( __( 'ERROR: The JSON payload you have included in your request is too large. Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: The JSON payload you have included in your request is too large. Status code is %1$s', 'post-smtp' ), $error_code ); break; case 429: - $message = sprintf( __( 'ERROR: The number of requests you have made exceeds SendGrid rate limitations. Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: The number of requests you have made exceeds SendGrid rate limitations. Status code is %1$s', 'post-smtp' ), $error_code ); break; case 500: - $message = sprintf( __( 'ERROR: An error occurred on a SendGrid server. Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: An error occurred on a SendGrid server. Status code is %1$s', 'post-smtp' ), $error_code ); break; case 513: - $message = sprintf( __( 'ERROR: The SendGrid v3 Web API is not available. Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: The SendGrid v3 Web API is not available. Status code is %1$s', 'post-smtp' ), $error_code ); break; case 502: - $message = sprintf( __( 'ERROR: No recipient supplied. Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: No recipient supplied. Status code is %1$s', 'post-smtp' ), $error_code ); break; default: - $message = sprintf( __( 'ERROR: Status code is %1$s', Postman::TEXT_DOMAIN ), $error_code ); + $message = sprintf( __( 'ERROR: Status code is %1$s', 'post-smtp' ), $error_code ); } return $message; diff --git a/Postman/Postman-Mail/PostmanSendGridTransport.php b/Postman/Postman-Mail/PostmanSendGridTransport.php index 358fcc5..efac416 100644 --- a/Postman/Postman-Mail/PostmanSendGridTransport.php +++ b/Postman/Postman-Mail/PostmanSendGridTransport.php @@ -16,7 +16,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements /** * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct($rootPluginFilenameAndPath) { parent::__construct ( $rootPluginFilenameAndPath ); @@ -36,7 +36,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements return self::SLUG; } public function getName() { - return __ ( 'SendGrid API', Postman::TEXT_DOMAIN ); + return __ ( 'SendGrid API', 'post-smtp' ); } /** * v0.2.1 @@ -49,7 +49,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements /** * v0.2.1 * - * @return string + * @return int */ public function getPort() { return self::PORT; @@ -76,12 +76,12 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements } public function getDeliveryDetails() { /* translators: where (1) is the secure icon and (2) is the transport name */ - return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', Postman::TEXT_DOMAIN ), '🔐', $this->getName () ); + return sprintf ( __ ( 'Postman will send mail via the <b>%1$s %2$s</b>.', 'post-smtp' ), '🔐', $this->getName () ); } /** * - * @param unknown $data + * @param mixed $data */ public function prepareOptionsForExport($data) { $data = parent::prepareOptionsForExport ( $data ); @@ -98,11 +98,11 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements $messages = parent::validateTransportConfiguration (); $apiKey = $this->options->getSendGridApiKey (); if (empty ( $apiKey )) { - array_push ( $messages, __ ( 'API Key can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push ( $messages, __ ( 'API Key can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady (); } if (! $this->isSenderConfigured ()) { - array_push ( $messages, __ ( 'Message From Address can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push ( $messages, __ ( 'Message From Address can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady (); } return $messages; @@ -129,8 +129,8 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements /** * - * @param unknown $hostname - * @param unknown $response + * @param mixed $hostname + * @param mixed $response */ public function populateConfiguration($hostname) { $response = parent::populateConfiguration ( $hostname ); @@ -145,7 +145,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements $overrideItem ['auth_items'] = array ( array ( 'selected' => true, - 'name' => __ ( 'API Key', Postman::TEXT_DOMAIN ), + 'name' => __ ( 'API Key', 'post-smtp' ), 'value' => 'api_key' ) ); @@ -174,25 +174,25 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements */ public function addSettings() { // the SendGrid Auth section - add_settings_section ( PostmanSendGridTransport::SENDGRID_AUTH_SECTION, __ ( 'Authentication', Postman::TEXT_DOMAIN ), array ( + add_settings_section ( PostmanSendGridTransport::SENDGRID_AUTH_SECTION, __ ( 'Authentication', 'post-smtp' ), array ( $this, 'printSendGridAuthSectionInfo' ), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS ); - add_settings_field ( PostmanOptions::SENDGRID_API_KEY, __ ( 'API Key', Postman::TEXT_DOMAIN ), array ( + add_settings_field ( PostmanOptions::SENDGRID_API_KEY, __ ( 'API Key', 'post-smtp' ), array ( $this, 'sendgrid_api_key_callback' ), PostmanSendGridTransport::SENDGRID_AUTH_OPTIONS, PostmanSendGridTransport::SENDGRID_AUTH_SECTION ); } public function printSendGridAuthSectionInfo() { /* Translators: Where (1) is the service URL and (2) is the service name and (3) is a api key URL */ - printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', Postman::TEXT_DOMAIN ), 'https://sendgrid.com', 'SendGrid.com', 'https://app.sendgrid.com/settings/api_keys' ) ); + printf ( '<p id="wizard_sendgrid_auth_help">%s</p>', sprintf ( __ ( 'Create an account at <a href="%1$s" target="_blank">%2$s</a> and enter <a href="%3$s" target="_blank">an API key</a> below.', 'post-smtp' ), 'https://sendgrid.com', 'SendGrid.com', 'https://app.sendgrid.com/settings/api_keys' ) ); } /** */ public function sendgrid_api_key_callback() { - printf ( '<input type="password" autocomplete="off" id="sendgrid_api_key" name="postman_options[sendgrid_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getSendGridApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getSendGridApiKey () ) ) : '', __ ( 'Required', Postman::TEXT_DOMAIN ) ); + printf ( '<input type="password" autocomplete="off" id="sendgrid_api_key" name="postman_options[sendgrid_api_key]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getSendGridApiKey () ? esc_attr ( PostmanUtils::obfuscatePassword ( $this->options->getSendGridApiKey () ) ) : '', __ ( 'Required', 'post-smtp' ) ); print ' <input type="button" id="toggleSendGridApiKey" value="Show Password" class="button button-secondary" style="visibility:hidden" />'; } @@ -219,7 +219,7 @@ class PostmanSendGridTransport extends PostmanAbstractModuleTransport implements public function printWizardAuthenticationStep() { print '<section class="wizard_sendgrid">'; $this->printSendGridAuthSectionInfo (); - printf ( '<label for="api_key">%s</label>', __ ( 'API Key', Postman::TEXT_DOMAIN ) ); + printf ( '<label for="api_key">%s</label>', __ ( 'API Key', 'post-smtp' ) ); print '<br />'; print $this->sendgrid_api_key_callback (); print '</section>'; diff --git a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php index 3bd1ad2..08e833f 100644 --- a/Postman/Postman-Mail/PostmanSmtpModuleTransport.php +++ b/Postman/Postman-Mail/PostmanSmtpModuleTransport.php @@ -91,21 +91,21 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl protected function validateTransportConfiguration() { $messages = parent::validateTransportConfiguration(); if ( ! $this->isHostConfigured( $this->options ) ) { - array_push( $messages, __( 'Outgoing Mail Server Hostname and Port can not be empty.', Postman::TEXT_DOMAIN ) ); + array_push( $messages, __( 'Outgoing Mail Server Hostname and Port can not be empty.', 'post-smtp' ) ); $this->setNotConfiguredAndReady(); } if ( ! $this->isEnvelopeFromConfigured() ) { - array_push( $messages, __( 'Envelope-From Email Address can not be empty', Postman::TEXT_DOMAIN ) . '.' ); + array_push( $messages, __( 'Envelope-From Email Address can not be empty', 'post-smtp' ) . '.' ); $this->setNotConfiguredAndReady(); } if ( $this->options->isAuthTypePassword() && ! $this->isPasswordAuthenticationConfigured( $this->options ) ) { - array_push( $messages, __( 'Username and password can not be empty.', Postman::TEXT_DOMAIN ) ); + array_push( $messages, __( 'Username and password can not be empty.', 'post-smtp' ) ); $this->setNotConfiguredAndReady(); } if ( $this->getAuthenticationType() == PostmanOptions::AUTHENTICATION_TYPE_OAUTH2 ) { if ( ! $this->isOAuth2SupportedHostConfigured() ) { /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label (e.g. Warning: OAuth 2.0 authentication requires an OAuth 2.0-capable Outgoing Mail Server, Sender Email Address, Client ID, and Client Secret.) */ - array_push( $messages, sprintf( __( 'OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server.', Postman::TEXT_DOMAIN ) ) ); + array_push( $messages, sprintf( __( 'OAuth 2.0 authentication requires a supported OAuth 2.0-capable Outgoing Mail Server.', 'post-smtp' ) ) ); $this->setNotConfiguredAndReady(); } } @@ -113,7 +113,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl $this->setReadyForOAuthGrant(); if ( $this->isPermissionNeeded( $this->options, $this->getOAuthToken() ) ) { /* translators: %1$s is the Client ID label, and %2$s is the Client Secret label */ - $message = sprintf( __( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', Postman::TEXT_DOMAIN ), $this->getScribe()->getClientIdLabel(), $this->getScribe()->getClientSecretLabel() ); + $message = sprintf( __( 'You have configured OAuth 2.0 authentication, but have not received permission to use it.', 'post-smtp' ), $this->getScribe()->getClientIdLabel(), $this->getScribe()->getClientSecretLabel() ); $message .= sprintf( ' <a href="%s">%s</a>.', PostmanUtils::getGrantOAuthPermissionUrl(), $this->getScribe()->getRequestPermissionLinkText() ); array_push( $messages, $message ); $this->setNotConfiguredAndReady(); @@ -160,7 +160,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl /** * SendGrid will never recommend it's configuration * - * @param unknown $hostData + * @param mixed $hostData */ public function getConfigurationBid( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) { $port = $hostData->port; @@ -265,7 +265,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl $authDesc = $this->getAuthenticationDescription( $recommendation ['auth'] ); $recommendation ['label'] = sprintf( 'SMTP - %2$s:%3$d', $transportDescription, $hostData->hostnameDomainOnly, $port ); /* translators: where %1$s is a description of the transport (eg. SMTPS-SSL), %2$s is a description of the authentication (eg. Password-CRAMMD5), %3$d is the TCP port (eg. 465), %4$d is the hostname */ - $recommendation ['message'] = sprintf( __( 'Postman recommends %1$s with %2$s authentication to host %4$s on port %3$d.', Postman::TEXT_DOMAIN ), $transportDescription, $authDesc, $port, $hostname ); + $recommendation ['message'] = sprintf( __( 'Postman recommends %1$s with %2$s authentication to host %4$s on port %3$d.', 'post-smtp' ), $transportDescription, $authDesc, $port, $hostname ); } // fill-in the rest of the recommendation @@ -322,53 +322,53 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl $oauthScribe = $transport->getScribe(); // Sanitize - add_settings_section( PostmanAdminController::SMTP_SECTION, __( 'Transport Settings', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::SMTP_SECTION, __( 'Transport Settings', 'post-smtp' ), array( $this, 'printSmtpSectionInfo', ), PostmanAdminController::SMTP_OPTIONS ); - add_settings_field( PostmanOptions::HOSTNAME, __( 'Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::HOSTNAME, __( 'Outgoing Mail Server Hostname', 'post-smtp' ), array( $this, 'hostname_callback', ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION ); - add_settings_field( PostmanOptions::PORT, __( 'Outgoing Mail Server Port', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::PORT, __( 'Outgoing Mail Server Port', 'post-smtp' ), array( $this, 'port_callback', ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION ); - add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Envelope-From Email Address', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::ENVELOPE_SENDER, __( 'Envelope-From Email Address', 'post-smtp' ), array( $this, 'sender_email_callback', ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION ); - add_settings_field( PostmanOptions::SECURITY_TYPE, _x( 'Security', 'Configuration Input Field', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::SECURITY_TYPE, _x( 'Security', 'Configuration Input Field', 'post-smtp' ), array( $this, 'encryption_type_callback', ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION ); - add_settings_field( PostmanOptions::AUTHENTICATION_TYPE, __( 'Authentication', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::AUTHENTICATION_TYPE, __( 'Authentication', 'post-smtp' ), array( $this, 'authentication_type_callback', ), PostmanAdminController::SMTP_OPTIONS, PostmanAdminController::SMTP_SECTION ); - add_settings_section( PostmanAdminController::BASIC_AUTH_SECTION, __( 'Authentication', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::BASIC_AUTH_SECTION, __( 'Authentication', 'post-smtp' ), array( $this, 'printBasicAuthSectionInfo', ), PostmanAdminController::BASIC_AUTH_OPTIONS ); - add_settings_field( PostmanOptions::BASIC_AUTH_USERNAME, __( 'Username', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::BASIC_AUTH_USERNAME, __( 'Username', 'post-smtp' ), array( $this, 'basic_auth_username_callback', ), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION ); - add_settings_field( PostmanOptions::BASIC_AUTH_PASSWORD, __( 'Password', Postman::TEXT_DOMAIN ), array( + add_settings_field( PostmanOptions::BASIC_AUTH_PASSWORD, __( 'Password', 'post-smtp' ), array( $this, 'basic_auth_password_callback', ), PostmanAdminController::BASIC_AUTH_OPTIONS, PostmanAdminController::BASIC_AUTH_SECTION ); // the OAuth section - add_settings_section( PostmanAdminController::OAUTH_SECTION, __( 'Authentication', Postman::TEXT_DOMAIN ), array( + add_settings_section( PostmanAdminController::OAUTH_SECTION, __( 'Authentication', 'post-smtp' ), array( $this, 'printOAuthSectionInfo', ), PostmanAdminController::OAUTH_AUTH_OPTIONS ); @@ -398,21 +398,21 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl * Print the Section text */ public function printSmtpSectionInfo() { - print __( 'Configure the communication with the mail server.', Postman::TEXT_DOMAIN ); + print __( 'Configure the communication with the mail server.', 'post-smtp' ); } /** * Get the settings option array and print one of its values */ public function hostname_callback() { - printf( '<input type="text" id="input_hostname" name="postman_options[hostname]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getHostname() ? esc_attr( $this->options->getHostname() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" id="input_hostname" name="postman_options[hostname]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getHostname() ? esc_attr( $this->options->getHostname() ) : '', __( 'Required', 'post-smtp' ) ); } /** * Get the settings option array and print one of its values */ public function port_callback( $args ) { - printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" id="input_port" name="postman_options[port]" value="%s" %s placeholder="%s"/>', null !== $this->options->getPort() ? esc_attr( $this->options->getPort() ) : '', isset( $args ['style'] ) ? $args ['style'] : '', __( 'Required', 'post-smtp' ) ); } /** @@ -421,7 +421,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl public function encryption_type_callback() { $encType = $this->options->getEncryptionType(); print '<select id="input_enc_type" class="input_encryption_type" name="postman_options[enc_type]">'; - printf( '<option class="input_enc_type_none" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_NONE, $encType == PostmanOptions::SECURITY_TYPE_NONE ? 'selected="selected"' : '', __( 'None', Postman::TEXT_DOMAIN ) ); + printf( '<option class="input_enc_type_none" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_NONE, $encType == PostmanOptions::SECURITY_TYPE_NONE ? 'selected="selected"' : '', __( 'None', 'post-smtp' ) ); printf( '<option class="input_enc_type_ssl" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_SMTPS, $encType == PostmanOptions::SECURITY_TYPE_SMTPS ? 'selected="selected"' : '', 'SMTPS' ); printf( '<option class="input_enc_type_tls" value="%s" %s>%s</option>', PostmanOptions::SECURITY_TYPE_STARTTLS, $encType == PostmanOptions::SECURITY_TYPE_STARTTLS ? 'selected="selected"' : '', 'STARTTLS' ); print '</select>'; @@ -445,7 +445,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl * Print the Section text */ public function printBasicAuthSectionInfo() { - print __( 'Enter the account credentials.', Postman::TEXT_DOMAIN ); + print __( 'Enter the account credentials.', 'post-smtp' ); } /** @@ -453,9 +453,9 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl */ public function basic_auth_username_callback() { $inputValue = (null !== $this->options->getUsername() ? esc_attr( $this->options->getUsername() ) : ''); - $inputDescription = __( 'The Username is usually the same as the Envelope-From Email Address.', Postman::TEXT_DOMAIN ); + $inputDescription = __( 'The Username is usually the same as the Envelope-From Email Address.', 'post-smtp' ); print ('<input tabindex="99" id="fake_user_name" name="fake_user[name]" style="position:absolute; top:-500px;" type="text" value="Safari Autofill Me">') ; - printf( '<input type="text" id="input_basic_auth_username" name="postman_options[basic_auth_username]" value="%s" size="40" class="required" placeholder="%s"/><br/><span class="postman_input_description">%s</span>', $inputValue, __( 'Required', Postman::TEXT_DOMAIN ), $inputDescription ); + printf( '<input type="text" id="input_basic_auth_username" name="postman_options[basic_auth_username]" value="%s" size="40" class="required" placeholder="%s"/><br/><span class="postman_input_description">%s</span>', $inputValue, __( 'Required', 'post-smtp' ), $inputDescription ); } /** @@ -463,7 +463,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl */ public function basic_auth_password_callback() { print ('<input tabindex="99" id="fake_password" name="fake[password]" style="position:absolute; top:-500px;" type="password" value="Safari Autofill Me">') ; - printf( '<input type="password" id="input_basic_auth_password" name="postman_options[basic_auth_password]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getPassword() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getPassword() ) ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="password" id="input_basic_auth_password" name="postman_options[basic_auth_password]" value="%s" size="40" class="required" placeholder="%s"/>', null !== $this->options->getPassword() ? esc_attr( PostmanUtils::obfuscatePassword( $this->options->getPassword() ) ) : '', __( 'Required', 'post-smtp' ) ); print ' <input type="button" id="togglePasswordField" value="Show Password" class="button button-secondary" style="visibility:hidden" />'; } @@ -471,14 +471,14 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl * Get the settings option array and print one of its values */ public function oauth_client_id_callback() { - printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" id="oauth_client_id" name="postman_options[oauth_client_id]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientId() ? esc_attr( $this->options->getClientId() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" id="oauth_client_id" name="postman_options[oauth_client_id]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientId() ? esc_attr( $this->options->getClientId() ) : '', __( 'Required', 'post-smtp' ) ); } /** * Get the settings option array and print one of its values */ public function oauth_client_secret_callback() { - printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" autocomplete="off" id="oauth_client_secret" name="postman_options[oauth_client_secret]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientSecret() ? esc_attr( $this->options->getClientSecret() ) : '', __( 'Required', Postman::TEXT_DOMAIN ) ); + printf( '<input type="text" onClick="this.setSelectionRange(0, this.value.length)" autocomplete="off" id="oauth_client_secret" name="postman_options[oauth_client_secret]" value="%s" size="60" class="required" placeholder="%s"/>', null !== $this->options->getClientSecret() ? esc_attr( $this->options->getClientSecret() ) : '', __( 'Required', 'post-smtp' ) ); } /** @@ -507,7 +507,7 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl $oauthScribe = $transport->getScribe(); return $oauthScribe->getCallbackDomain(); } catch ( Exception $e ) { - return __( 'Error computing your domain root - please enter it manually', Postman::TEXT_DOMAIN ); + return __( 'Error computing your domain root - please enter it manually', 'post-smtp' ); } } @@ -526,28 +526,28 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl */ public function sender_email_callback() { $inputValue = (null !== $this->options->getEnvelopeSender() ? esc_attr( $this->options->getEnvelopeSender() ) : ''); - $requiredLabel = __( 'Required', Postman::TEXT_DOMAIN ); - $envelopeFromMessage = __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', Postman::TEXT_DOMAIN ); - $spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_blank" href="%s">SPF record</a> permitting the use of the SMTP server named above.', Postman::TEXT_DOMAIN ), 'https://www.mail-tester.com/spf/' ); + $requiredLabel = __( 'Required', 'post-smtp' ); + $envelopeFromMessage = __( 'This address, like the <b>return address</b> printed on an envelope, identifies the account owner to the SMTP server.', 'post-smtp' ); + $spfMessage = sprintf( __( 'For reliable delivery, this domain must specify an <a target="_blank" href="%s">SPF record</a> permitting the use of the SMTP server named above.', 'post-smtp' ), 'https://www.mail-tester.com/spf/' ); printf( '<input type="email" id="input_envelope_sender_email" name="postman_options[envelope_sender]" value="%s" size="40" class="required" placeholder="%s"/> <br/><span class="postman_input_description">%s %s</span>', $inputValue, $requiredLabel, $envelopeFromMessage, $spfMessage ); } /** */ public function printWizardMailServerHostnameStep() { - printf( '<legend>%s</legend>', _x( 'Which host will relay the mail?', 'Wizard Step Title', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'This is the Outgoing (SMTP) Mail Server, or Mail Submission Agent (MSA), which Postman delegates mail delivery to. This server is specific to your email account, and if you don\'t know what to use, ask your email service provider.', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'Note that many WordPress hosts, such as GoDaddy, Bluehost and Dreamhost, require that you use their mail accounts with their mail servers, and prevent you from using others.', Postman::TEXT_DOMAIN ) ); - printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', _x( 'Which host will relay the mail?', 'Wizard Step Title', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'This is the Outgoing (SMTP) Mail Server, or Mail Submission Agent (MSA), which Postman delegates mail delivery to. This server is specific to your email account, and if you don\'t know what to use, ask your email service provider.', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'Note that many WordPress hosts, such as GoDaddy, Bluehost and Dreamhost, require that you use their mail accounts with their mail servers, and prevent you from using others.', 'post-smtp' ) ); + printf( '<label for="hostname">%s</label>', __( 'Outgoing Mail Server Hostname', 'post-smtp' ) ); print $this->hostname_callback(); printf( '<p class="ajax-loader" style="display:none"><img src="%s"/></p>', plugins_url( 'post-smtp/style/ajax-loader.gif' ) ); - $warning = __( 'Warning', Postman::TEXT_DOMAIN ); + $warning = __( 'Warning', 'post-smtp' ); /* Translators: Where (%s) is the name of the web host */ - $nonGodaddyDomainMessage = sprintf( __( 'Your email address <b>requires</b> access to a remote SMTP server blocked by %s.', Postman::TEXT_DOMAIN ), 'GoDaddy' ); - $nonGodaddyDomainMessage .= sprintf( ' %s', __( 'If you have access to cPanel, enable the Remote Mail Exchanger.', Postman::TEXT_DOMAIN ) ); + $nonGodaddyDomainMessage = sprintf( __( 'Your email address <b>requires</b> access to a remote SMTP server blocked by %s.', 'post-smtp' ), 'GoDaddy' ); + $nonGodaddyDomainMessage .= sprintf( ' %s', __( 'If you have access to cPanel, enable the Remote Mail Exchanger.', 'post-smtp' ) ); printf( '<p id="godaddy_block"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $nonGodaddyDomainMessage ); /* Translators: Where (%1$s) is the SPF-info URL and (%2$s) is the name of the web host */ - $godaddyCustomDomainMessage = sprintf( __( 'If you own this domain, make sure it has an <a href="%1$s">SPF record authorizing %2$s</a> as a relay, or you will have delivery problems.', Postman::TEXT_DOMAIN ), 'http://www.mail-tester.com/spf/godaddy', 'GoDaddy' ); + $godaddyCustomDomainMessage = sprintf( __( 'If you own this domain, make sure it has an <a href="%1$s">SPF record authorizing %2$s</a> as a relay, or you will have delivery problems.', 'post-smtp' ), 'http://www.mail-tester.com/spf/godaddy', 'GoDaddy' ); printf( '<p id="godaddy_spf_required"><span style="background-color:yellow"><b>%s</b>: %s</span></p>', $warning, $godaddyCustomDomainMessage ); } @@ -575,12 +575,12 @@ class PostmanSmtpModuleTransport extends PostmanAbstractZendModuleTransport impl print '</section>'; print '<section class="wizard-auth-basic">'; - printf( '<p class="port-explanation-ssl">%s</p>', __( 'Enter the account credentials.', Postman::TEXT_DOMAIN ) ); - printf( '<label for="username">%s</label>', __( 'Username', Postman::TEXT_DOMAIN ) ); + printf( '<p class="port-explanation-ssl">%s</p>', __( 'Enter the account credentials.', 'post-smtp' ) ); + printf( '<label for="username">%s</label>', __( 'Username', 'post-smtp' ) ); print '<br />'; print $this->basic_auth_username_callback(); print '<br />'; - printf( '<label for="password">%s</label>', __( 'Password', Postman::TEXT_DOMAIN ) ); + printf( '<label for="password">%s</label>', __( 'Password', 'post-smtp' ) ); print '<br />'; print $this->basic_auth_password_callback(); print '</section>'; diff --git a/Postman/Postman-Mail/PostmanTransportRegistry.php b/Postman/Postman-Mail/PostmanTransportRegistry.php index e86f1f4..5af2493 100644 --- a/Postman/Postman-Mail/PostmanTransportRegistry.php +++ b/Postman/Postman-Mail/PostmanTransportRegistry.php @@ -39,7 +39,7 @@ class PostmanTransportRegistry { * B) when querying what a theoretical scenario involving this transport is like * (ie.for ajax in config screen) * - * @param unknown $slug + * @param mixed $slug */ public function getTransport( $slug ) { $transports = $this->getTransports(); @@ -61,7 +61,7 @@ class PostmanTransportRegistry { /** * Determine if a specific transport is registered in the directory. * - * @param unknown $slug + * @param mixed $slug */ public function isRegistered( $slug ) { $transports = $this->getTransports(); @@ -71,7 +71,7 @@ class PostmanTransportRegistry { /** * Retrieve the transport Postman is currently configured with. * - * @return PostmanDummyTransport|PostmanModuleTransport + * @return PostmanModuleTransport * @deprecated */ public function getCurrentTransport() { @@ -105,7 +105,7 @@ class PostmanTransportRegistry { /** * Retrieve the transport Postman is currently configured with. * - * @return PostmanDummyTransport|PostmanModuleTransport + * @return PostmanModuleTransport */ public function getSelectedTransport() { $selectedTransport = PostmanOptions::getInstance()->getTransportType(); @@ -143,8 +143,8 @@ class PostmanTransportRegistry { /** * Polls all the installed transports to get a complete list of sockets to probe for connectivity * - * @param unknown $hostname - * @param unknown $isGmail + * @param mixed $hostname + * @param mixed $isGmail * @return multitype: */ public function getSocketsForSetupWizardToProbe( $hostname = 'localhost', $smtpServerGuess = null ) { @@ -178,7 +178,7 @@ class PostmanTransportRegistry { * * response should include ['success'], ['message'], ['priority'] * - * @param unknown $hostData + * @param mixed $hostData */ public function getRecommendation( PostmanWizardSocket $hostData, $userAuthOverride, $originalSmtpServer ) { $scrubbedUserAuthOverride = $this->scrubUserOverride( $hostData, $userAuthOverride ); @@ -193,7 +193,7 @@ class PostmanTransportRegistry { /** * * @param PostmanWizardSocket $hostData - * @param unknown $userAuthOverride + * @param mixed $userAuthOverride * @return NULL */ private function scrubUserOverride( PostmanWizardSocket $hostData, $userAuthOverride ) { @@ -231,18 +231,18 @@ class PostmanTransportRegistry { if ( PostmanOptions::getInstance()->getRunMode() != PostmanOptions::RUN_MODE_PRODUCTION ) { return array( 'error' => true, - 'message' => __( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', Postman::TEXT_DOMAIN ), + 'message' => __( 'Postman is in <em>non-Production</em> mode and is dumping all emails.', 'post-smtp' ), ); } else { return array( 'error' => false, - 'message' => __( 'Postman is configured.', Postman::TEXT_DOMAIN ), + 'message' => __( 'Postman is configured.', 'post-smtp' ), ); } } else { return array( 'error' => true, - 'message' => __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', Postman::TEXT_DOMAIN ), + 'message' => __( 'Postman is <em>not</em> configured and is mimicking out-of-the-box WordPress email delivery.', 'post-smtp' ), ); } } diff --git a/Postman/Postman-Mail/PostmanWooCommerce.php b/Postman/Postman-Mail/PostmanWooCommerce.php index a6a2e82..feee32e 100644 --- a/Postman/Postman-Mail/PostmanWooCommerce.php +++ b/Postman/Postman-Mail/PostmanWooCommerce.php @@ -28,7 +28,7 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { return array( - array( 'title' => __( 'Email notifications', Postman::TEXT_DOMAIN ), 'desc' => __( 'Email notifications sent from WooCommerce are listed below. Click on an email to configure it.', Postman::TEXT_DOMAIN ), 'type' => 'title', 'id' => 'email_notification_settings' ), + array( 'title' => __( 'Email notifications', 'post-smtp' ), 'desc' => __( 'Email notifications sent from WooCommerce are listed below. Click on an email to configure it.', 'post-smtp' ), 'type' => 'title', 'id' => 'email_notification_settings' ), array( 'type' => 'email_notification' ), @@ -36,11 +36,11 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ), - array( 'title' => __( 'Email sender options', Postman::TEXT_DOMAIN ), 'type' => 'title', 'desc' => '', 'id' => 'email_options' ), + array( 'title' => __( 'Email sender options', 'post-smtp' ), 'type' => 'title', 'desc' => '', 'id' => 'email_options' ), array( - 'title' => __( '"From" name', Postman::TEXT_DOMAIN ), - 'desc' => __( 'How the sender name appears in outgoing WooCommerce emails.', Postman::TEXT_DOMAIN ), + 'title' => __( '"From" name', 'post-smtp' ), + 'desc' => __( 'How the sender name appears in outgoing WooCommerce emails.', 'post-smtp' ), 'id' => 'woocommerce_email_from_name', 'type' => 'text', 'css' => 'min-width:300px;', @@ -50,8 +50,8 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { ), array( - 'title' => __( '"From" address', Postman::TEXT_DOMAIN ), - 'desc' => __( 'This is overided by the account configured on Post SMTP plugin configuration.', Postman::TEXT_DOMAIN ), + 'title' => __( '"From" address', 'post-smtp' ), + 'desc' => __( 'This is overided by the account configured on Post SMTP plugin configuration.', 'post-smtp' ), 'id' => 'woocommerce_email_from_address', 'type' => 'email', 'custom_attributes' => array( @@ -66,26 +66,26 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { array( 'type' => 'sectionend', 'id' => 'email_options' ), - array( 'title' => __( 'Email template', Postman::TEXT_DOMAIN ), 'type' => 'title', 'desc' => sprintf( __( 'This section lets you customize the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>.', Postman::TEXT_DOMAIN ), wp_nonce_url( admin_url( '?preview_woocommerce_mail=true' ), 'preview-mail' ) ), 'id' => 'email_template_options' ), + array( 'title' => __( 'Email template', 'post-smtp' ), 'type' => 'title', 'desc' => sprintf( __( 'This section lets you customize the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>.', 'post-smtp' ), wp_nonce_url( admin_url( '?preview_woocommerce_mail=true' ), 'preview-mail' ) ), 'id' => 'email_template_options' ), array( - 'title' => __( 'Header image', Postman::TEXT_DOMAIN ), - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', Postman::TEXT_DOMAIN ), + 'title' => __( 'Header image', 'post-smtp' ), + 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'post-smtp' ), 'id' => 'woocommerce_email_header_image', 'type' => 'text', 'css' => 'min-width:300px;', - 'placeholder' => __( 'N/A', Postman::TEXT_DOMAIN ), + 'placeholder' => __( 'N/A', 'post-smtp' ), 'default' => '', 'autoload' => false, 'desc_tip' => true, ), array( - 'title' => __( 'Footer text', Postman::TEXT_DOMAIN ), - 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', Postman::TEXT_DOMAIN ), + 'title' => __( 'Footer text', 'post-smtp' ), + 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', 'post-smtp' ), 'id' => 'woocommerce_email_footer_text', 'css' => 'width:300px; height: 75px;', - 'placeholder' => __( 'N/A', Postman::TEXT_DOMAIN ), + 'placeholder' => __( 'N/A', 'post-smtp' ), 'type' => 'textarea', /* translators: %s: site name */ 'default' => get_bloginfo( 'name', 'display' ), @@ -94,9 +94,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { ), array( - 'title' => __( 'Base color', Postman::TEXT_DOMAIN ), + 'title' => __( 'Base color', 'post-smtp' ), /* translators: %s: default color */ - 'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', Postman::TEXT_DOMAIN ), '<code>#96588a</code>' ), + 'desc' => sprintf( __( 'The base color for WooCommerce email templates. Default %s.', 'post-smtp' ), '<code>#96588a</code>' ), 'id' => 'woocommerce_email_base_color', 'type' => 'color', 'css' => 'width:6em;', @@ -106,9 +106,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { ), array( - 'title' => __( 'Background color', Postman::TEXT_DOMAIN ), + 'title' => __( 'Background color', 'post-smtp' ), /* translators: %s: default color */ - 'desc' => sprintf( __( 'The background color for WooCommerce email templates. Default %s.', Postman::TEXT_DOMAIN ), '<code>#f7f7f7</code>' ), + 'desc' => sprintf( __( 'The background color for WooCommerce email templates. Default %s.', 'post-smtp' ), '<code>#f7f7f7</code>' ), 'id' => 'woocommerce_email_background_color', 'type' => 'color', 'css' => 'width:6em;', @@ -118,9 +118,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { ), array( - 'title' => __( 'Body background color', Postman::TEXT_DOMAIN ), + 'title' => __( 'Body background color', 'post-smtp' ), /* translators: %s: default color */ - 'desc' => sprintf( __( 'The main body background color. Default %s.', Postman::TEXT_DOMAIN ), '<code>#ffffff</code>' ), + 'desc' => sprintf( __( 'The main body background color. Default %s.', 'post-smtp' ), '<code>#ffffff</code>' ), 'id' => 'woocommerce_email_body_background_color', 'type' => 'color', 'css' => 'width:6em;', @@ -130,9 +130,9 @@ if ( ! class_exists( 'PostmanWoocommerce' ) ) { ), array( - 'title' => __( 'Body text color', Postman::TEXT_DOMAIN ), + 'title' => __( 'Body text color', 'post-smtp' ), /* translators: %s: default color */ - 'desc' => sprintf( __( 'The main body text color. Default %s.', Postman::TEXT_DOMAIN ), '<code>#3c3c3c</code>' ), + 'desc' => sprintf( __( 'The main body text color. Default %s.', 'post-smtp' ), '<code>#3c3c3c</code>' ), 'id' => 'woocommerce_email_text_color', 'type' => 'color', 'css' => 'width:6em;', diff --git a/Postman/Postman-Mail/PostmanZendMailEngine.php b/Postman/Postman-Mail/PostmanZendMailEngine.php index 8d69811..86905f8 100644 --- a/Postman/Postman-Mail/PostmanZendMailEngine.php +++ b/Postman/Postman-Mail/PostmanZendMailEngine.php @@ -47,8 +47,8 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) { /** * - * @param unknown $senderEmail - * @param unknown $accessToken + * @param mixed $senderEmail + * @param mixed $accessToken */ function __construct( PostmanZendModuleTransport $transport ) { assert( isset( $transport ) ); @@ -171,10 +171,12 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) { $this->logger->debug( 'Create the Zend_Mail transport' ); $zendTransport = $this->transport->createZendMailTransport( $this->transport->getHostname(), array() ); + $transport = $this->transport instanceof PostmanDefaultModuleTransport ? null : $zendTransport; + try { // send the message $this->logger->debug( 'Sending mail' ); - $mail->send( $zendTransport ); + $mail->send( $transport ); if ( $this->logger->isInfo() ) { $this->logger->info( sprintf( 'Message %d accepted for delivery', PostmanState::getInstance()->getSuccessfulDeliveries() + 1 ) ); } @@ -204,7 +206,7 @@ if ( ! class_exists( 'PostmanZendMailEngine' ) ) { $message = $e->getMessage(); if ( $e->getCode() == 334 ) { // replace the unusable Google message with a better one in the case of code 334 - $message = sprintf( __( 'Communication Error [334] - make sure the Envelope From email is the same account used to create the Client ID.', Postman::TEXT_DOMAIN ) ); + $message = sprintf( __( 'Communication Error [334] - make sure the Envelope From email is the same account used to create the Client ID.', 'post-smtp' ) ); } // create a new exception $newException = new Exception( $message, $e->getCode() ); diff --git a/Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php b/Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php index 2639497..08e1810 100644 --- a/Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php +++ b/Postman/Postman-Mail/PostmanZendMailTransportConfigurationFactory.php @@ -78,11 +78,11 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) { * * Create the Configuration structure for Zend_Mail * - * @param unknown $hostname - * @param unknown $port - * @param unknown $securityType - * @param unknown $authenticationType - * @param unknown $initClientRequestEncoded + * @param mixed $hostname + * @param mixed $port + * @param mixed $securityType + * @param mixed $authenticationType + * @param mixed $initClientRequestEncoded * @return multitype:unknown NULL */ private static function createConfiguration($logger, $hostname, $port, $securityType, $authenticationType, $initClientRequestEncoded) { @@ -99,7 +99,7 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) { /** * Create the vendor string (for Yahoo servers only) * - * @param unknown $hostname + * @param mixed $hostname * @return string */ private static function createVendorString($hostname) { @@ -116,9 +116,9 @@ if (! class_exists ( 'PostmanOAuth2ConfigurationFactory' )) { /** * Create the standard OAuth2 SMTP Authentication string * - * @param unknown $senderEmail - * @param unknown $oauth2AccessToken - * @param unknown $vendor + * @param mixed $senderEmail + * @param mixed $oauth2AccessToken + * @param mixed $vendor * @return string */ private static function createAuthenticationString($senderEmail, $oauth2AccessToken, $vendor) { diff --git a/Postman/Postman-Mail/Zend-1.12.10/Mail.php b/Postman/Postman-Mail/Zend-1.12.10/Mail.php index b2204f7..67ba4b9 100644 --- a/Postman/Postman-Mail/Zend-1.12.10/Mail.php +++ b/Postman/Postman-Mail/Zend-1.12.10/Mail.php @@ -365,7 +365,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message } $mp = new Postman_Zend_Mime_Part($txt); - $mp->encoding = $encoding; + $mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_TEXT); $mp->type = Postman_Zend_Mime::TYPE_TEXT; $mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE; $mp->charset = $charset; @@ -406,7 +406,7 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message } $mp = new Postman_Zend_Mime_Part($html); - $mp->encoding = $encoding; + $mp->encoding = apply_filters( 'post_smtp_content_transfer_encoding', $encoding, Postman_Zend_Mime::TYPE_HTML ); $mp->type = Postman_Zend_Mime::TYPE_HTML; $mp->disposition = Postman_Zend_Mime::DISPOSITION_INLINE; $mp->charset = $charset; @@ -1175,10 +1175,9 @@ class Postman_Zend_Mail extends Postman_Zend_Mime_Message { if ($transport === null) { if (! self::$_defaultTransport instanceof Postman_Zend_Mail_Transport_Abstract) { - require_once 'Zend/Mail/Transport/Sendmail.php'; - - $replyTo = self::getDefaultReplyTo(); - $transport = new Postman_Zend_Mail_Transport_Sendmail("-f{$replyTo['email']}"); + require_once 'Mail/Transport/Sendmail.php'; + + $transport = new Postman_Zend_Mail_Transport_Sendmail("-f{$this->_from}"); } else { $transport = self::$_defaultTransport; } diff --git a/Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php b/Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php index 537c330..f51645b 100644 --- a/Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php +++ b/Postman/Postman-Mail/Zend-1.12.10/Validate/EmailAddress.php @@ -321,7 +321,7 @@ class Postman_Zend_Validate_EmailAddress extends Postman_Zend_Validate_Abstract /** * Returns the set domainCheck option * - * @return unknown + * @return mixed */ public function getDomainCheck() { diff --git a/Postman/Postman-Mail/sendgrid/composer.json b/Postman/Postman-Mail/sendgrid/composer.json index dbcdefd..95d93ce 100644 --- a/Postman/Postman-Mail/sendgrid/composer.json +++ b/Postman/Postman-Mail/sendgrid/composer.json @@ -1,5 +1,5 @@ { "require": { - "sendgrid/sendgrid": "~6.0" + "sendgrid/sendgrid": "~7" } -} +}
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/composer.lock b/Postman/Postman-Mail/sendgrid/composer.lock index 22d21cb..fd6a6e2 100644 --- a/Postman/Postman-Mail/sendgrid/composer.lock +++ b/Postman/Postman-Mail/sendgrid/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "72f70d0a56dace06ee80667ae9467dc2", - "content-hash": "31a416743df03ec89ce9f557ff36c18e", + "hash": "cb037c28e262c69616caad2764cb3a4f", + "content-hash": "907e285f65325b51e424d991537f18af", "packages": [ { "name": "sendgrid/php-http-client", - "version": "3.8.0", + "version": "3.9.6", "source": { "type": "git", "url": "https://github.com/sendgrid/php-http-client.git", - "reference": "929018c62b7fcd99b3b356216ae75fff4d47b5a1" + "reference": "e9a04d949ee2d19938ab83dc100933a3b41a8ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sendgrid/php-http-client/zipball/929018c62b7fcd99b3b356216ae75fff4d47b5a1", - "reference": "929018c62b7fcd99b3b356216ae75fff4d47b5a1", + "url": "https://api.github.com/repos/sendgrid/php-http-client/zipball/e9a04d949ee2d19938ab83dc100933a3b41a8ec7", + "reference": "e9a04d949ee2d19938ab83dc100933a3b41a8ec7", "shasum": "" }, "require": { @@ -57,53 +57,64 @@ "rest", "sendgrid" ], - "time": "2017-09-13 16:52:38" + "time": "2018-04-10 18:06:08" }, { "name": "sendgrid/sendgrid", - "version": "6.0.0", + "version": "7.3.0", "source": { "type": "git", "url": "https://github.com/sendgrid/sendgrid-php.git", - "reference": "8db454e4b5674b545c207a162b64202b0d63259b" + "reference": "37fa19d3ae019842f07a2a43e92ed0f566ad927d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sendgrid/sendgrid-php/zipball/8db454e4b5674b545c207a162b64202b0d63259b", - "reference": "8db454e4b5674b545c207a162b64202b0d63259b", + "url": "https://api.github.com/repos/sendgrid/sendgrid-php/zipball/37fa19d3ae019842f07a2a43e92ed0f566ad927d", + "reference": "37fa19d3ae019842f07a2a43e92ed0f566ad927d", "shasum": "" }, "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", "php": ">=5.6", - "sendgrid/php-http-client": "~3.7" + "sendgrid/php-http-client": "~3.9" }, "replace": { "sendgrid/sendgrid-php": "*" }, "require-dev": { - "phpunit/phpunit": "4.*", - "squizlabs/php_codesniffer": "2.*" + "phpunit/phpunit": "^5.7.9 || ^6.4.3", + "squizlabs/php_codesniffer": "3.*", + "swaggest/json-diff": "^3.4" }, "type": "library", "autoload": { + "psr-4": { + "SendGrid\\": "lib/", + "SendGrid\\Mail\\": "lib/mail/", + "SendGrid\\Contacts\\": "lib/contacts/", + "SendGrid\\Stats\\": "lib/stats/" + }, "files": [ - "lib/SendGrid.php", - "lib/helpers/mail/Mail.php" + "lib/SendGrid.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "This library allows you to quickly and easily send emails through SendGrid using PHP.", + "description": "This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.", "homepage": "http://github.com/sendgrid/sendgrid-php", "keywords": [ "email", "grid", "send", - "sendgrid" + "sendgrid", + "twilio sendgrid" ], - "time": "2017-07-01 04:30:16" + "time": "2019-04-15 17:27:21" } ], "packages-dev": [], diff --git a/Postman/Postman-Mail/sendgrid/vendor/autoload.php b/Postman/Postman-Mail/sendgrid/vendor/autoload.php index cb30775..764afb2 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/autoload.php +++ b/Postman/Postman-Mail/sendgrid/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68::getLoader(); +return ComposerAutoloaderInitb8261ccd2bb9e98223bcd166b46db8d9::getLoader(); diff --git a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_files.php b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_files.php index c6a74bd..4d74b3d 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_files.php +++ b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_files.php @@ -7,5 +7,4 @@ $baseDir = dirname($vendorDir); return array( '3f8bdd3b35094c73a26f0106e3c0f8b2' => $vendorDir . '/sendgrid/sendgrid/lib/SendGrid.php', - '9dda55337a76a24e949fbcc5d905a2c7' => $vendorDir . '/sendgrid/sendgrid/lib/helpers/mail/Mail.php', ); diff --git a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_psr4.php b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_psr4.php index 89751b9..7618d79 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_psr4.php +++ b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_psr4.php @@ -6,5 +6,8 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'SendGrid\\' => array($vendorDir . '/sendgrid/php-http-client/lib'), + 'SendGrid\\Stats\\' => array($vendorDir . '/sendgrid/sendgrid/lib/stats'), + 'SendGrid\\Mail\\' => array($vendorDir . '/sendgrid/sendgrid/lib/mail'), + 'SendGrid\\Contacts\\' => array($vendorDir . '/sendgrid/sendgrid/lib/contacts'), + 'SendGrid\\' => array($vendorDir . '/sendgrid/php-http-client/lib', $vendorDir . '/sendgrid/sendgrid/lib'), ); diff --git a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_real.php b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_real.php index 81518bf..35b4612 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_real.php +++ b/Postman/Postman-Mail/sendgrid/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68 +class ComposerAutoloaderInitb8261ccd2bb9e98223bcd166b46db8d9 { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitb8261ccd2bb9e98223bcd166b46db8d9', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitb8261ccd2bb9e98223bcd166b46db8d9', 'loadClassLoader')); $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -42,14 +42,14 @@ class ComposerAutoloaderInit31a2dc55ed2dc338fb6b79b1af891c68 $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire31a2dc55ed2dc338fb6b79b1af891c68($fileIdentifier, $file); + composerRequireb8261ccd2bb9e98223bcd166b46db8d9($fileIdentifier, $file); } return $loader; } } -function composerRequire31a2dc55ed2dc338fb6b79b1af891c68($fileIdentifier, $file) +function composerRequireb8261ccd2bb9e98223bcd166b46db8d9($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/Postman/Postman-Mail/sendgrid/vendor/composer/installed.json b/Postman/Postman-Mail/sendgrid/vendor/composer/installed.json index b3d9001..f86362a 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/composer/installed.json +++ b/Postman/Postman-Mail/sendgrid/vendor/composer/installed.json @@ -1,17 +1,17 @@ [ { "name": "sendgrid/php-http-client", - "version": "3.8.0", - "version_normalized": "3.8.0.0", + "version": "3.9.6", + "version_normalized": "3.9.6.0", "source": { "type": "git", "url": "https://github.com/sendgrid/php-http-client.git", - "reference": "929018c62b7fcd99b3b356216ae75fff4d47b5a1" + "reference": "e9a04d949ee2d19938ab83dc100933a3b41a8ec7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sendgrid/php-http-client/zipball/929018c62b7fcd99b3b356216ae75fff4d47b5a1", - "reference": "929018c62b7fcd99b3b356216ae75fff4d47b5a1", + "url": "https://api.github.com/repos/sendgrid/php-http-client/zipball/e9a04d949ee2d19938ab83dc100933a3b41a8ec7", + "reference": "e9a04d949ee2d19938ab83dc100933a3b41a8ec7", "shasum": "" }, "require": { @@ -21,7 +21,7 @@ "phpunit/phpunit": "~4.4", "squizlabs/php_codesniffer": "~2.0" }, - "time": "2017-09-13 16:52:38", + "time": "2018-04-10 18:06:08", "type": "library", "installation-source": "dist", "autoload": { @@ -55,50 +55,61 @@ }, { "name": "sendgrid/sendgrid", - "version": "6.0.0", - "version_normalized": "6.0.0.0", + "version": "7.3.0", + "version_normalized": "7.3.0.0", "source": { "type": "git", "url": "https://github.com/sendgrid/sendgrid-php.git", - "reference": "8db454e4b5674b545c207a162b64202b0d63259b" + "reference": "37fa19d3ae019842f07a2a43e92ed0f566ad927d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sendgrid/sendgrid-php/zipball/8db454e4b5674b545c207a162b64202b0d63259b", - "reference": "8db454e4b5674b545c207a162b64202b0d63259b", + "url": "https://api.github.com/repos/sendgrid/sendgrid-php/zipball/37fa19d3ae019842f07a2a43e92ed0f566ad927d", + "reference": "37fa19d3ae019842f07a2a43e92ed0f566ad927d", "shasum": "" }, "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", "php": ">=5.6", - "sendgrid/php-http-client": "~3.7" + "sendgrid/php-http-client": "~3.9" }, "replace": { "sendgrid/sendgrid-php": "*" }, "require-dev": { - "phpunit/phpunit": "4.*", - "squizlabs/php_codesniffer": "2.*" + "phpunit/phpunit": "^5.7.9 || ^6.4.3", + "squizlabs/php_codesniffer": "3.*", + "swaggest/json-diff": "^3.4" }, - "time": "2017-07-01 04:30:16", + "time": "2019-04-15 17:27:21", "type": "library", "installation-source": "dist", "autoload": { + "psr-4": { + "SendGrid\\": "lib/", + "SendGrid\\Mail\\": "lib/mail/", + "SendGrid\\Contacts\\": "lib/contacts/", + "SendGrid\\Stats\\": "lib/stats/" + }, "files": [ - "lib/SendGrid.php", - "lib/helpers/mail/Mail.php" + "lib/SendGrid.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "This library allows you to quickly and easily send emails through SendGrid using PHP.", + "description": "This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.", "homepage": "http://github.com/sendgrid/sendgrid-php", "keywords": [ "email", "grid", "send", - "sendgrid" + "sendgrid", + "twilio sendgrid" ] } ] diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/ISSUE_TEMPLATE b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/ISSUE_TEMPLATE index f6eac95..94a2122 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/ISSUE_TEMPLATE +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/ISSUE_TEMPLATE @@ -14,4 +14,4 @@ Any other information you want to share that is relevant to the issue being repo #### Technical details: * php-http-client Version: master (latest commit: [commit number]) -* PHP Version: 5.x +* PHP Version: X.X diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore index bc9ed87..b90ffc5 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.gitignore @@ -1,6 +1,11 @@ -.env -*.lock +# Composer vendor/ +*.phar +*.lock + +# Jetbrains Idea *.old .idea/ -*.phar + +# Environment files +.env/*.*
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.travis.yml b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.travis.yml index c9ad9ca..0ba5d28 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.travis.yml +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.travis.yml @@ -3,7 +3,9 @@ before_script: - composer install --dev --no-interaction - cd test/unit script: -- ../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test* --coverage-clover clover.xml +- ../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test* --coverage-clover=coverage.xml +after_success: +- bash <(curl -s https://codecov.io/bash) php: - 5.6 - 7.0 @@ -22,4 +24,4 @@ notifications: Build %{build_number}</a> on branch <i>%{branch}</i> by %{author}: <strong>%{message}</strong> <a href="https://github.com/%{repository}/commits/%{commit}">View on GitHub</a>' format: html - notify: true
\ No newline at end of file + notify: true diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CHANGELOG.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CHANGELOG.md deleted file mode 100644 index fb45f8d..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CHANGELOG.md +++ /dev/null @@ -1,64 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -This project adheres to [Semantic Versioning](http://semver.org/). - -## [3.8.0] - 2017-09-13 -### Added -- Pull request #23: [Automatically retry when rate limit is reached](https://github.com/sendgrid/php-http-client/pull/23) -- Thanks to [Budi Chandra](https://github.com/budirec) for the pull request! - -## [3.7.0] - 2017-05-04 -### Added -- Pull request #19: [Added ability to get headers as associative array](https://github.com/sendgrid/php-http-client/pull/19) -- Solves issue #361: [https://github.com/sendgrid/sendgrid-php/issues/361](https://github.com/sendgrid/sendgrid-php/issues/361) -- Thanks to [Alexander](https://github.com/mazanax) for the pull request! - -## [3.6.0] - 2017-03-01 -### Added -- Pull request #16: [Pass the curlOptions to the client in buildClient](https://github.com/sendgrid/php-http-client/pull/16) -- Thanks to [Baptiste Clavié](https://github.com/Taluu) for the pull request! - -## [3.5.1] - 2016-11-17 -### Fixed -- Pull request #13, fixed issue #12: [Change from to php union operator to combine curl options](https://github.com/sendgrid/php-http-client/pull/13) -- Thanks to [emil](https://github.com/emilva) for the pull request! - -## [3.5.0] - 2016-10-18 -### Added -- Pull request #11: [Added curlOptions property to customize curl instance](https://github.com/sendgrid/php-http-client/pull/11) -- Thanks to [Alain Tiemblo](https://github.com/ninsuo) for the pull request! - -## [3.4.0] - 2016-09-27 -### Added -- Pull request #9: [Add getters for certain properties](https://github.com/sendgrid/php-http-client/pull/9) -- Thanks to [Arjan Keeman](https://github.com/akeeman) for the pull request! - -## [3.3.0] - 2016-09-13 -### Added -- Pull request #6: [Library refactoring around PSR-2 / PSR-4 code standards](https://github.com/sendgrid/php-http-client/pull/6) -- Thanks to [Alexandr Ivanov](https://github.com/misantron) for the pull request! - -## [3.1.0] - 2016-06-10 -### Added -- Automatically add Content-Type: application/json when there is a request body - -## [3.0.0] - 2016-06-06 -### Changed -- Made the Request and Response variables non-redundant. e.g. request.requestBody becomes request.body - -## [2.0.2] - 2016-02-29 -### Fixed -- Renaming files to conform to PSR-0, git ignored the case in 2.0.1 - -## [2.0.1] - 2016-02-29 -### Fixed -- Renaming files to conform to PSR-0 - -## [1.0.1] - 2016-02-29 -### Fixed -- Composer/Packagist install issues resolved - -## [1.0.0] - 2016-02-29 -### Added -- We are live! diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CONTRIBUTING.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CONTRIBUTING.md index 6350054..6b01be8 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CONTRIBUTING.md +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CONTRIBUTING.md @@ -2,13 +2,14 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou - [CLAs and CCLAs](#cla) - [Roadmap & Milestones](#roadmap) -- [Feature Request](#feature_request) -- [Submit a Bug Report](#submit_a_bug_report) -- [Improvements to the Codebase](#improvements_to_the_codebase) -- [Understanding the Code Base](#understanding_the_codebase) +- [Feature Request](#feature-request) +- [Submit a Bug Report](#submit-a-bug-report) +- [Improvements to the Codebase](#improvements-to-the-codebase) +- [Understanding the Code Base](#understanding-the-codebase) - [Testing](#testing) -- [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions) -- [Creating a Pull Request](#creating_a_pull_request) +- [Style Guidelines & Naming Conventions](#style-guidelines-and-naming-conventions) +- [Creating a Pull Request](#creating-a-pull-request) +- [Code Reviews](#code-reviews) <a name="roadmap"></a> We use [Milestones](https://github.com/sendgrid/php-http-client/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged. @@ -26,7 +27,7 @@ When you create a Pull Request, after a few seconds, a comment will appear with There are a few ways to contribute, which we'll enumerate below: -<a name="feature_request"></a> +<a name="feature-request"></a> ## Feature Request If you'd like to make a feature request, please read this section. @@ -36,7 +37,7 @@ The GitHub issue tracker is the preferred channel for library feature requests, - Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests. - Please be respectful and considerate of others when commenting on issues -<a name="submit_a_bug_report"></a> +<a name="submit-a-bug-report"></a> ## Submit a Bug Report Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public. @@ -53,7 +54,7 @@ Before you decide to create a new issue, please try the following: In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/php-http-client/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting. -<a name="improvements_to_the_codebase"></a> +<a name="improvements-to-the-codebase"></a> ## Improvements to the Codebase We welcome direct contributions to the php-http-client code base. Thank you! @@ -74,7 +75,7 @@ git clone https://github.com/sendgrid/php-http-client.git cd php-http-client ``` -## Environment Variables +### Environment Variables First, get your free SendGrid account [here](https://sendgrid.com/free?source=php-http-client). @@ -88,8 +89,9 @@ source ./sendgrid.env ##### Execute: ##### -See the [examples folder](https://github.com/sendgrid/php-http-client/tree/master/examples -<a name="understanding_the_codebase"></a> +See the [examples folder](https://github.com/sendgrid/php-http-client/tree/master/examples). + +<a name="understanding-the-codebase"></a> ## Understanding the Code Base **/examples** @@ -127,7 +129,7 @@ cd test/unit ../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test* ``` -<a name="style_guidelines_and_naming_conventions"></a> +<a name="style-guidelines-and-naming-conventions"></a> ## Style Guidelines & Naming Conventions Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning. @@ -138,7 +140,8 @@ Please run your code through: - [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) -## Creating a Pull Request<a name="creating_a_pull_request"></a> +<a name="creating-a-pull-request"></a> +## Creating a Pull Request 1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: @@ -147,7 +150,7 @@ Please run your code through: # Clone your fork of the repo into the current directory git clone https://github.com/sendgrid/php-http-client # Navigate to the newly cloned directory - cd sendgrid-python + cd php-http-client # Assign the original repo to a remote called "upstream" git remote add upstream https://github.com/sendgrid/php-http-client ``` @@ -191,4 +194,8 @@ Please run your code through: 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch. All tests must be passing before we will review the PR. +<a name="code-reviews"></a> +## Code Reviews +If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/). + If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/LICENSE.txt b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/LICENSE.txt index c1631d6..8a3ef00 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/LICENSE.txt +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 SendGrid, Inc. +Copyright (c) 2012-2018 SendGrid, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/README.md index 0eb7ce8..ef7236a 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/README.md +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/README.md @@ -1,4 +1,11 @@ +![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) + [![Travis Badge](https://travis-ci.org/sendgrid/php-http-client.svg?branch=master)](https://travis-ci.org/sendgrid/php-http-client) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/sendgrid/php-http-client.svg?style=flat-square)](https://packagist.org/packages/sendgrid/php-http-client) +[![Email Notifications Badge](https://dx.sendgrid.com/badge/php)](https://dx.sendgrid.com/newsletter/php) +[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid) +[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/php-http-client.svg)](https://github.com/sendgrid/php-http-client/graphs/contributors) +[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt) **Quickly and easily access any RESTful or RESTful-like API.** @@ -8,6 +15,17 @@ If you are looking for the SendGrid API client library, please see [this repo](h All updates to this library is documented in our [CHANGELOG](https://github.com/sendgrid/php-http-client/blob/master/CHANGELOG.md). +# Table of Contents +- [Installation](#installation) +- [Quick Start](#quick-start) +- [Usage](#usage) +- [Roadmap](#roadmap) +- [How to Contribute](#contribute) +- [Thanks](#thanks) +- [About](#about) +- [License](#license) + +<a name="installation"></a> # Installation ## Prerequisites @@ -21,7 +39,7 @@ Add php-http-client to your `composer.json` file. If you are not using [Composer ```json { "require": { - "sendgrid/php-http-client": "~3.8" + "sendgrid/php-http-client": "~3.9.6" } } ``` @@ -38,6 +56,44 @@ Then from the command line: composer install ``` +## Install without Composer + +You should create directory `lib` in directory of your application and clone to `lib` repositories [php-http-client](https://github.com/sendgrid/php-http-client.git) and [sendgrid-php](https://github.com/sendgrid/sendgrid-php.git): + +``` +$ cd /path/to/your/app +$ mkdir lib +$ cd lib +$ git clone https://github.com/sendgrid/php-http-client.git +``` + +In the next step you should create `loader.php`: + +``` +$ cd /path/to/your/app +$ touch loader.php +``` + +And add to `loader.php` code below: + +```php +<?php + +require_once __DIR__ . '/lib/php-http-client/lib/Client.php'; +require_once __DIR__ . '/lib/php-http-client/lib/Response.php'; +``` + +After it you can use `php-http-client` library in your project: + +```php +<?php + +include __DIR__ . '/loader.php'; + +$client = new SendGrid\Client(); +``` + +<a name="quick-start"></a> # Quick Start Here is a quick example: @@ -45,59 +101,95 @@ Here is a quick example: `GET /your/api/{param}/call` ```php +// include __DIR__ . '/loader.php'; require 'vendor/autoload.php'; -$global_headers = array(Authorization: Basic XXXXXXX); -$client = SendGrid\Client('base_url', global_headers); +$apiKey = YOUR_SENDGRID_API_KEY; +$authHeaders = [ + 'Authorization: Bearer ' . $apiKey +]; +$client = new SendGrid\Client('https://api.sendgrid.com', $authHeaders); +$param = 'foo'; $response = $client->your()->api()->_($param)->call()->get(); -print $response->statusCode(); -print $response->headers(); -print $response->body(); + +var_dump( + $response->statusCode(), + $response->headers(), + $response->body() +); ``` `POST /your/api/{param}/call` with headers, query parameters and a request body with versioning. ```php +// include __DIR__ . '/loader.php'; require 'vendor/autoload.php'; -$global_headers = array(Authorization: Basic XXXXXXX); -$client = SendGrid\Client('base_url', global_headers); -$query_params = array('hello' => 0, 'world' => 1); -$request_headers = array('X-Test' => 'test'); -$data = array('some' => 1, 'awesome' => 2, 'data' => 3); -$response = $client->your()->api()->_($param)->call()->post('data', - 'query_params', - 'request_headers'); -print $response->statusCode(); -print $response->headers(); -print $response->body(); +$apiKey = YOUR_SENDGRID_API_KEY; +$authHeaders = [ + 'Authorization: Bearer ' . $apiKey +]; +$client = new SendGrid\Client('https://api.sendgrid.com', $authHeaders); +$queryParams = [ + 'hello' => 0, 'world' => 1 +]; +$requestHeaders = [ + 'X-Test' => 'test' +]; +$data = [ + 'some' => 1, 'awesome' => 2, 'data' => 3 +]; +$param = 'bar'; +$response = $client->your()->api()->_($param)->call()->post($data, $queryParams, $requestHeaders); + +var_dump( + $response->statusCode(), + $response->headers(), + $response->body() +); ``` +<a name="usage"></a> # Usage -- [Example Code](https://github.com/sendgrid/php-http-client/tree/master/examples) +- [Usage Examples](USAGE.md) + +## Environment Variables + +You can do the following to create a .env file: -## Roadmap +```cp .env_example .env``` -If you are intersted in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/php-http-client/milestones). We would love to hear your feedback. +Then, just add your API Key into your .env file. -## How to Contribute +<a name="roadmap"></a> +# Roadmap -We encourage contribution to our libraries, please see our [CONTRIBUTING](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md)) guide for details. +If you are interested in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/php-http-client/milestones). We would love to hear your feedback. + +<a name="contribute"></a> +# How to Contribute + +We encourage contribution to our libraries, please see our [CONTRIBUTING](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md) guide for details. Quick links: -- [Feature Request](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#feature_request) -- [Bug Reports](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#submit_a_bug_report) +- [Feature Request](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#feature-request) +- [Bug Reports](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#submit-a-bug-report) - [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#cla) -- [Improvements to the Codebase](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#improvements_to_the_codebase) +- [Improvements to the Codebase](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#improvements-to-the-codebase) +- [Review Pull Requests](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md#code-reviews) +<a name="thanks"></a> # Thanks We were inspired by the work done on [birdy](https://github.com/inueni/birdy) and [universalclient](https://github.com/dgreisen/universalclient). +<a name="about"></a> # About php-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com). php-http-client is maintained and funded by SendGrid, Inc. The names and logos for php-http-client are trademarks of SendGrid, Inc. -![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) +<a name="license"></a> +# License +[The MIT License (MIT)](LICENSE.txt) diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/composer.json b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/composer.json index 80b219b..5c0a3af 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/composer.json +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/composer.json @@ -2,11 +2,7 @@ "name": "sendgrid/php-http-client", "description": "HTTP REST client, simplified for PHP", "type": "library", - "version": "3.8.0", - "require-dev": { - "phpunit/phpunit": "~4.4", - "squizlabs/php_codesniffer": "~2.0" - }, + "version": "3.9.6", "homepage": "http://github.com/sendgrid/php-http-client", "keywords": ["SendGrid", "HTTP", "REST", "API", "Fluent"], "license": "MIT", @@ -23,6 +19,10 @@ "require": { "php": ">=5.6" }, + "require-dev": { + "phpunit/phpunit": "~4.4", + "squizlabs/php_codesniffer": "~2.0" + }, "autoload": { "psr-4": { "SendGrid\\": "lib/" diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Client.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Client.php index d3ca94d..ec732b9 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Client.php +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Client.php @@ -1,46 +1,225 @@ <?php /** - * HTTP Client library - * - * PHP version 5.4 - * - * @author Matt Bernier <dx@sendgrid.com> - * @author Elmer Thomas <dx@sendgrid.com> - * @copyright 2016 SendGrid - * @license https://opensource.org/licenses/MIT The MIT License - * @version GIT: <git_id> - * @link http://packagist.org/packages/sendgrid/php-http-client - */ + * HTTP Client library + * + * @author Matt Bernier <dx@sendgrid.com> + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018 SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/php-http-client + */ namespace SendGrid; /** - * Quickly and easily access any REST or REST-like API. - */ + * + * Class Client + * @package SendGrid + * @version 3.9.5 + * + * Quickly and easily access any REST or REST-like API. + * + * @method Response get($body = null, $query = null, $headers = null) + * @method Response post($body = null, $query = null, $headers = null) + * @method Response patch($body = null, $query = null, $headers = null) + * @method Response put($body = null, $query = null, $headers = null) + * @method Response delete($body = null, $query = null, $headers = null) + * + * @method Client version($value) + * @method Client|Response send() + * + * Adding all the endpoints as a method so code completion works + * + * General + * @method Client stats() + * @method Client search() + * @method Client monthly() + * @method Client sums() + * @method Client monitor() + * @method Client test() + * + * Access settings + * @method Client access_settings() + * @method Client activity() + * @method Client whitelist() + * + * Alerts + * @method Client alerts() + * + * Api keys + * @method Client api_keys() + * + * ASM + * @method Client asm() + * @method Client groups() + * + * Browsers + * @method Client browsers() + * + * Campaigns + * @method Client campaigns() + * @method Client schedules() + * @method Client now() + * + * Categories + * @method Client categories() + * + * Clients + * @method Client clients() + * + * ContactDB + * @method Client contactdb() + * @method Client custom_fields() + * @method Client lists() + * @method Client recipients() + * @method Client billable_count() + * @method Client count() + * @method Client reserved_fields() + * @method Client segments() + * + * Devices + * @method Client devices() + * + * Geo + * @method Client geo() + * + * Ips + * @method Client ips() + * @method Client assigned() + * @method Client pools() + * @method Client warmup() + * + * Mail + * @method Client mail() + * @method Client batch() + * + * Mailbox Providers + * @method Client mailbox_providers() + * + * Mail settings + * @method Client mail_settings() + * @method Client address_whitelist() + * @method Client bcc() + * @method Client bounce_purge() + * @method Client footer() + * @method Client forward_bounce() + * @method Client forward_spam() + * @method Client plain_content() + * @method Client spam_check() + * @method Client template() + * + * Partner settings + * @method Client partner_settings() + * @method Client new_relic() + * + * Scopes + * @method Client scopes() + * + * Senders + * @method Client senders() + * @method Client resend_verification() + * + * Sub Users + * @method Client subusers() + * @method Client reputations() + * + * Supressions + * @method Client suppressions() + * @method Client global() + * @method Client blocks() + * @method Client bounces() + * @method Client invalid_emails() + * @method Client spam_reports() + * @method Client unsubcribes() + * + * Templates + * @method Client templates() + * @method Client versions() + * @method Client activate() + * + * Tracking settings + * @method Client tracking_settings() + * @method Client click() + * @method Client google_analytics() + * @method Client open() + * @method Client subscription() + * + * User + * @method Client user() + * @method Client account() + * @method Client credits() + * @method Client email() + * @method Client password() + * @method Client profile() + * @method Client scheduled_sends() + * @method Client enforced_tls() + * @method Client settings() + * @method Client username() + * @method Client webhooks() + * @method Client event() + * @method Client parse() + * + * Missed any? Simply add them by doing: @method Client method() + */ class Client { - /** @var string */ + const TOO_MANY_REQUESTS_HTTP_CODE = 429; + + /** + * @var string + */ protected $host; - /** @var array */ + + /** + * @var array + */ protected $headers; - /** @var string */ + + /** + * @var string + */ protected $version; - /** @var array */ + + /** + * @var array + */ protected $path; - /** @var array */ + + /** + * @var array + */ protected $curlOptions; - /** @var array */ - private $methods; - /** @var bool */ - private $retryOnLimit; + + /** + * @var bool + */ + protected $isConcurrentRequest; + + /** + * @var array + */ + protected $savedRequests; + + /** + * @var bool + */ + protected $retryOnLimit; + + /** + * These are the supported HTTP verbs + * + * @var array + */ + private $methods = ['get', 'post', 'patch', 'put', 'delete']; /** * Initialize the client * * @param string $host the base url (e.g. https://api.sendgrid.com) * @param array $headers global request headers - * @param string $version api version (configurable) + * @param string $version api version (configurable) - this is specific to the SendGrid API * @param array $path holds the segments of the url path * @param array $curlOptions extra options to set during curl initialization * @param bool $retryOnLimit set default retry on limit flag @@ -52,10 +231,9 @@ class Client $this->version = $version; $this->path = $path ?: []; $this->curlOptions = $curlOptions ?: []; - // These are the supported HTTP verbs - $this->methods = ['delete', 'get', 'patch', 'post', 'put']; - $this->retryOnLimit = $retryOnLimit; + $this->isConcurrentRequest = false; + $this->savedRequests = []; } /** @@ -99,29 +277,54 @@ class Client } /** - * Make a new Client object - * - * @param string $name name of the url segment - * - * @return Client object - */ - private function buildClient($name = null) + * Set extra options to set during curl initialization + * + * @param array $options + * + * @return Client + */ + public function setCurlOptions(array $options) { - if (isset($name)) { - $this->path[] = $name; - } - $client = new Client($this->host, $this->headers, $this->version, $this->path, $this->curlOptions); - $this->path = []; - return $client; + $this->curlOptions = $options; + + return $this; } /** - * Build the final URL to be passed - * - * @param array $queryParams an array of all the query parameters - * - * @return string - */ + * Set default retry on limit flag + * + * @param bool $retry + * + * @return Client + */ + public function setRetryOnLimit($retry) + { + $this->retryOnLimit = $retry; + + return $this; + } + + /** + * Set concurrent request flag + * + * @param bool $isConcurrent + * + * @return Client + */ + public function setIsConcurrentRequest($isConcurrent) + { + $this->isConcurrentRequest = $isConcurrent; + + return $this; + } + + /** + * Build the final URL to be passed + * + * @param array $queryParams an array of all the query parameters + * + * @return string + */ private function buildUrl($queryParams = null) { $path = '/' . implode('/', $this->path); @@ -132,86 +335,231 @@ class Client } /** - * Make the API call and return the response. This is separated into - * it's own function, so we can mock it easily for testing. - * - * @param string $method the HTTP verb - * @param string $url the final url to call - * @param array $body request body - * @param array $headers any additional request headers - * @param bool $retryOnLimit should retry if rate limit is reach? - * - * @return Response object - */ - public function makeRequest($method, $url, $body = null, $headers = null, $retryOnLimit = false) + * Creates curl options for a request + * this function does not mutate any private variables + * + * @param string $method + * @param array $body + * @param array $headers + * + * @return array + */ + private function createCurlOptions($method, $body = null, $headers = null) { - $curl = curl_init($url); - - curl_setopt_array($curl, [ - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HEADER => 1, - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_SSL_VERIFYPEER => false, - ] + $this->curlOptions); + $options = [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HEADER => true, + CURLOPT_CUSTOMREQUEST => strtoupper($method), + CURLOPT_SSL_VERIFYPEER => true, + CURLOPT_FAILONERROR => false + ] + $this->curlOptions; if (isset($headers)) { - $this->headers = array_merge($this->headers, $headers); + $headers = array_merge($this->headers, $headers); + } else { + $headers = $this->headers; } + if (isset($body)) { $encodedBody = json_encode($body); - curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedBody); - $this->headers = array_merge($this->headers, ['Content-Type: application/json']); + $options[CURLOPT_POSTFIELDS] = $encodedBody; + $headers = array_merge($headers, ['Content-Type: application/json']); + } + $options[CURLOPT_HTTPHEADER] = $headers; + + return $options; + } + + /** + * @param array $requestData + * e.g. ['method' => 'POST', 'url' => 'www.example.com', 'body' => 'test body', 'headers' => []] + * @param bool $retryOnLimit + * + * @return array + */ + private function createSavedRequest(array $requestData, $retryOnLimit = false) + { + return array_merge($requestData, ['retryOnLimit' => $retryOnLimit]); + } + + /** + * @param array $requests + * + * @return array + */ + private function createCurlMultiHandle(array $requests) + { + $channels = []; + $multiHandle = curl_multi_init(); + + foreach ($requests as $id => $data) { + $channels[$id] = curl_init($data['url']); + $curlOpts = $this->createCurlOptions($data['method'], $data['body'], $data['headers']); + curl_setopt_array($channels[$id], $curlOpts); + curl_multi_add_handle($multiHandle, $channels[$id]); } - curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers); - $response = curl_exec($curl); - $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + return [$channels, $multiHandle]; + } + + /** + * Prepare response object + * + * @param resource $channel the curl resource + * @param string $content + * + * @return Response object + */ + private function parseResponse($channel, $content) + { + $headerSize = curl_getinfo($channel, CURLINFO_HEADER_SIZE); + $statusCode = curl_getinfo($channel, CURLINFO_HTTP_CODE); - $responseBody = substr($response, $headerSize); - $responseHeaders = substr($response, 0, $headerSize); + $responseBody = substr($content, $headerSize); + $responseHeaders = substr($content, 0, $headerSize); $responseHeaders = explode("\n", $responseHeaders); $responseHeaders = array_map('trim', $responseHeaders); - curl_close($curl); - - $response = new Response($statusCode, $responseBody, $responseHeaders); + return new Response($statusCode, $responseBody, $responseHeaders); + } - if ($statusCode == 429 && $retryOnLimit) { - $headers = $response->headers(true); - $sleepDurations = $headers['X-Ratelimit-Reset'] - time(); - sleep($sleepDurations > 0 ? $sleepDurations : 0); - return $this->makeRequest($method, $url, $body, $headers, false); + /** + * Retry request + * + * @param array $responseHeaders headers from rate limited response + * @param string $method the HTTP verb + * @param string $url the final url to call + * @param array $body request body + * @param array $headers original headers + * + * @return Response response object + */ + private function retryRequest(array $responseHeaders, $method, $url, $body, $headers) + { + $sleepDurations = $responseHeaders['X-Ratelimit-Reset'] - time(); + sleep($sleepDurations > 0 ? $sleepDurations : 0); + return $this->makeRequest($method, $url, $body, $headers, false); + } + + /** + * Make the API call and return the response. + * This is separated into it's own function, so we can mock it easily for testing. + * + * @param string $method the HTTP verb + * @param string $url the final url to call + * @param array $body request body + * @param array $headers any additional request headers + * @param bool $retryOnLimit should retry if rate limit is reach? + * + * @return Response object + */ + public function makeRequest($method, $url, $body = null, $headers = null, $retryOnLimit = false) + { + $channel = curl_init($url); + + $options = $this->createCurlOptions($method, $body, $headers); + + curl_setopt_array($channel, $options); + $content = curl_exec($channel); + + $response = $this->parseResponse($channel, $content); + + if ($response->statusCode() === self::TOO_MANY_REQUESTS_HTTP_CODE && $retryOnLimit) { + $responseHeaders = $response->headers(true); + return $this->retryRequest($responseHeaders, $method, $url, $body, $headers); } + curl_close($channel); + return $response; } /** - * Add variable values to the url. - * (e.g. /your/api/{variable_value}/call) - * Another example: if you have a PHP reserved word, such as and, - * in your url, you must use this method. - * - * @param string $name name of the url segment - * - * @return Client object - */ + * Send all saved requests at once + * + * @param array $requests + * + * @return Response[] + */ + public function makeAllRequests(array $requests = []) + { + if (empty($requests)) { + $requests = $this->savedRequests; + } + list($channels, $multiHandle) = $this->createCurlMultiHandle($requests); + + // running all requests + $isRunning = null; + do { + curl_multi_exec($multiHandle, $isRunning); + } while ($isRunning); + + // get response and close all handles + $retryRequests = []; + $responses = []; + $sleepDurations = 0; + foreach ($channels as $id => $channel) { + + $content = curl_multi_getcontent($channel); + $response = $this->parseResponse($channel, $content); + + if ($response->statusCode() === self::TOO_MANY_REQUESTS_HTTP_CODE && $requests[$id]['retryOnLimit']) { + $headers = $response->headers(true); + $sleepDurations = max($sleepDurations, $headers['X-Ratelimit-Reset'] - time()); + $requestData = [ + 'method' => $requests[$id]['method'], + 'url' => $requests[$id]['url'], + 'body' => $requests[$id]['body'], + 'headers' => $headers, + ]; + $retryRequests[] = $this->createSavedRequest($requestData, false); + } else { + $responses[] = $response; + } + + curl_multi_remove_handle($multiHandle, $channel); + } + curl_multi_close($multiHandle); + + // retry requests + if (!empty($retryRequests)) { + sleep($sleepDurations > 0 ? $sleepDurations : 0); + $responses = array_merge($responses, $this->makeAllRequests($retryRequests)); + } + return $responses; + } + + /** + * Add variable values to the url. (e.g. /your/api/{variable_value}/call) + * Another example: if you have a PHP reserved word, such as and, in your url, you must use this method. + * + * @param string $name name of the url segment + * + * @return Client object + */ public function _($name = null) { - return $this->buildClient($name); + if (isset($name)) { + $this->path[] = $name; + } + $client = new static($this->host, $this->headers, $this->version, $this->path); + $client->setCurlOptions($this->curlOptions); + $client->setRetryOnLimit($this->retryOnLimit); + $this->path = []; + + return $client; } /** - * Dynamically add method calls to the url, then call a method. - * (e.g. client.name.name.method()) - * - * @param string $name name of the dynamic method call or HTTP verb - * @param array $args parameters passed with the method call - * - * @return Client|Response object - */ + * Dynamically add method calls to the url, then call a method. + * (e.g. client.name.name.method()) + * + * @param string $name name of the dynamic method call or HTTP verb + * @param array $args parameters passed with the method call + * + * @return Client|Response|Response[]|null object + */ public function __call($name, $args) { $name = strtolower($name); @@ -221,12 +569,25 @@ class Client return $this->_(); } + // send all saved requests + if (($name === 'send') && $this->isConcurrentRequest) { + return $this->makeAllRequests(); + } + if (in_array($name, $this->methods, true)) { $body = isset($args[0]) ? $args[0] : null; $queryParams = isset($args[1]) ? $args[1] : null; $url = $this->buildUrl($queryParams); $headers = isset($args[2]) ? $args[2] : null; $retryOnLimit = isset($args[3]) ? $args[3] : $this->retryOnLimit; + + if ($this->isConcurrentRequest) { + // save request to be sent later + $requestData = ['method' => $name, 'url' => $url, 'body' => $body, 'headers' => $headers]; + $this->savedRequests[] = $this->createSavedRequest($requestData, $retryOnLimit); + return null; + } + return $this->makeRequest($name, $url, $body, $headers, $retryOnLimit); } diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Response.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Response.php index 29720f0..f658f2c 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Response.php +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/lib/Response.php @@ -3,11 +3,9 @@ /** * HTTP Client library * - * PHP version 5.4 - * * @author Matt Bernier <dx@sendgrid.com> * @author Elmer Thomas <dx@sendgrid.com> - * @copyright 2016 SendGrid + * @copyright 2018 SendGrid * @license https://opensource.org/licenses/MIT The MIT License * @version GIT: <git_id> * @link http://packagist.org/packages/sendgrid/php-http-client @@ -20,21 +18,29 @@ namespace SendGrid; */ class Response { - /** @var int */ + /** + * @var int + */ protected $statusCode; - /** @var string */ + + /** + * @var string + */ protected $body; - /** @var array */ + + /** + * @var array + */ protected $headers; /** * Setup the response data * - * @param int $statusCode the status code. - * @param string $body the response body. - * @param array $headers an array of response headers. + * @param int $statusCode the status code. + * @param string $body the response body. + * @param array $headers an array of response headers. */ - public function __construct($statusCode = null, $body = null, $headers = null) + public function __construct($statusCode = 200, $body = '', array $headers = []) { $this->statusCode = $statusCode; $this->body = $body; @@ -79,25 +85,16 @@ class Response /** * Returns response headers as associative array - * + * * @param array $headers * * @return array - * - * @throws \InvalidArgumentException */ - private function prettifyHeaders($headers) + private function prettifyHeaders(array $headers) { - if (!is_array($headers)) { - throw new \InvalidArgumentException('$headers should be array'); - } - return array_reduce( array_filter($headers), function ($result, $header) { - if (empty($header)) { - return $result; - } if (false === strpos($header, ':')) { $result['Status'] = trim($header); @@ -105,7 +102,7 @@ class Response return $result; } - list ($key, $value) = explode(':', $header, 2); + list($key, $value) = explode(':', $header, 2); $result[trim($key)] = trim($value); return $result; diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/ISSUE_TEMPLATE b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/ISSUE_TEMPLATE index 8e2d043..d378427 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/ISSUE_TEMPLATE +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/ISSUE_TEMPLATE @@ -2,7 +2,6 @@ A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples. - #### Steps to Reproduce 1. This is the first step @@ -14,4 +13,4 @@ Any other information you want to share that is relevant to the issue being repo #### Technical details: * sendgrid-php Version: master (latest commit: [commit number]) -* PHP Version: 5.x
\ No newline at end of file +* PHP Version: 5.6, 7.0, 7.1, 7.2 (as of May 17, 2018) diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore index 8f8f4f1..efe514c 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.gitignore @@ -2,9 +2,18 @@ test/coverage/* dist/ composer.lock vendor -.env* +.env sendgrid.env composer.phar .editorconfig test.php -.idea/
\ No newline at end of file +.idea/ +test/prism_linux_amd64 +test/prism/* +!test/prim +*.code-workspace +.vscode +prism* +temp.php +example*.php +TODO.txt diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.travis.yml b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.travis.yml index 068c594..c222a38 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.travis.yml +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.travis.yml @@ -1,27 +1,26 @@ language: php + before_script: -before_script: -- mkdir prism -- mkdir prism/bin -- export PATH=$PATH:$PWD/prism/bin/ -- ./test/prism.sh - composer install -- cd test/unit +- "./test/prism.sh &" +- sleep 60 +- cd test + script: -- "../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test*" +- "../vendor/bin/phpunit . --filter test*" + after_script: -- cd ../.. -- ./scripts/s3upload.sh +- cd ../ +after_success: +- bash <(curl -s https://codecov.io/bash) + php: - 5.6 - 7.0 -env: - global: - - S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLXBocC8iXSwKICAgIFsiY29udGVudC1sZW5ndGgtcmFuZ2UiLCAyMDQ4LCAyNjg0MzU0NTZdLAogICAgWyJlcSIsICIkQ29udGVudC1UeXBlIiwgImFwcGxpY2F0aW9uL3ppcCJdCiAgXQp9Cgo= - - secure: eUN0huKA436uIkISu6V3yW01/gZHC6slBvlnprMPEhzclU2szH6qhWEXWS5CcOG6EEDBReqLZdNAwu+FC69KGFO9+6oW2GQQLSsfEViqFi/Ig2N0r4EBO4jLRebgq0GOfetPwQvJH27d8BCiloPy8rXBb5pskxSNw4B4bRyXHz4= - - secure: j38xzMNmzYXR/JJdVumPmDoDVxb6FUDF497AuVPHowGh0egFW8XHWCOMeQWqWZI4Gg17pViQNIJ3xC6WBvob70AF8fsNm0+vxF2s7abXDMcbq5flLTS6ydKLgNu+na/RAkOBbTwxJAGIH/fQh8BH8iGKerCwoqf8sDErAge4NMw= - - secure: h3HlxBOsNXBDrIJ0yl467ST6Q8R2TmbL7PltlPcRoHy5gAxn5UiDv5W2+6DSXrwQrTjOUunZ+O9ckcaQGQy1JNhGMwgIkJpyWAHDIHhTYGU289uUIDTHQW/soX0qHJSHSx3iMgDOIc7XnfTz6W7Nv1gYKZFedOMsZ5uBMeGyiXE= - - secure: SKSl/RHFQNhGT7OUj7E0AbrQnuDhhCRI/4jC76mmzvy8EJBDgUNevAKJGtug+LVilHrlbk9fLC8rayPW6SGv0s3PowTGm8NMOc48aRBLOr7QRo/sMikJCmRuU6HWptr0NKuf2fq6lV94WDm/pDdyOSNyLga9/eaIDs/Sacp78sw= +- 7.1 +- 7.2 +- 7.3 + notifications: hipchat: rooms: diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CHANGELOG.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CHANGELOG.md deleted file mode 100644 index dd55517..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CHANGELOG.md +++ /dev/null @@ -1,207 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -This project adheres to [Semantic Versioning](http://semver.org/). - -## [6.0.0] - 2017-06-30 ## -### BREAKING CHANGE -- PR #408: Update Mail constructor to signify which parameters are required for sending all email -- The `Mail()` constructor now requires `$from`, `$subject`, `$to` and `$content` parameters like so: `Mail($from, $subject, $to, $content)`. Those are the minimaly required paramaters to send an email. -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.6.2] - 2017-06-29 ## -### Fix -- PR #410: Adding name for ReplyTo for issue #390 -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.6.1] - 2017-06-26 ## -### Fix -- Versioning mistake (forgot the .0 at the end) - -## [5.6.0] - 2017-06-26 ## -### Added -- Pull #405: Updating docs and non-composer includes -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.5.1] - 2017-05-18 ## -### Fixed -- Pull #396: Use `print_r` instead of `echo` on Arrays -- Thanks to [Ryan P.C. McQuen](https://github.com/ryanpcmcquen) for the PR! - -## [5.5.0] - 2017-05-04 ## -### Added -- Pull #393: Update [php-http-client](https://github.com/sendgrid/php-http-client) dependency -- [v3.6](https://github.com/sendgrid/php-http-client/releases/tag/v3.6.0): Pass the curlOptions to the client in buildClient -- [v3.7](https://github.com/sendgrid/php-http-client/releases/tag/v3.7.0): Added ability to get headers as associative array - -## [5.4.2] - 2017-04-18 ## -### Fixes -- Fixes #292 -- Removes Prism file in sendgrid-php.zip - -## [5.4.1] - 2017-04-04 ## -### Added -- Pull #373 -- PSR1 & PSR2 Conversion -- Thanks to [Braunson Yager](https://github.com/Braunson) for the PR! - -## [5.4.0] - 2017-03-16 ## -### Added -- Pull #337 -- API level addressing of the string-only custom arg rule -- Thanks to [Chris Schuld](https://github.com/cbschuld) for the PR! - -## [5.3.0] - 2017-03-15 ## -### Added -- Pull #367 -- UTF8 encoding forced for content value and message subject -- Thanks to [Chris Schuld](https://github.com/cbschuld) for the PR! - -## [5.2.3] - 2017-03-03 ## -### Fixed -- Pull #334 -- Fixed serialization of empty JSON objects, fixes #332 & #314 -- Thanks to [Matthew Dreyer](https://github.com/Dreyer) for the PR! - -## [5.2.2] - 2017-03-03 ## -### Fixed -- Pull #323 -- Typo 'user' for 'usr' -- Thanks to [Mike Ralphson](https://github.com/MikeRalphson) for the PR! - -## [5.2.1] - 2017-03-01 ## -### Fixed -- Pull #353 -- Fixed Issue #352 -- Relative path fix for background jobs -- Thanks to [Tarcísio Zotelli Ferraz](https://github.com/tarcisiozf) for the PR! - -## [5.2.0] - 2017-02-23 ## -### Added -- Pull #346 -- Allow passing curlOptions to the client -- Thanks to [Taluu](https://github.com/sendgrid/sendgrid-php/pull/346) for the PR! - -## [5.1.2] - 2016-10-11 ## -### Added -- Pull #330, Fixes #320 -- Delete subaccounts returns 200 issue resolved -- The fix happened at the [php-http-client](https://github.com/sendgrid/php-http-client/releases/tag/v3.5.1) dependency. -- Thanks to [emil](https://github.com/emilva) for the PR! - -## [5.1.1] - 2016-10-11 ## -### Added -- Pull #307, Fixes #276 -- Adds phpdoc and style fixes -- Thanks to [Avishkar Autar](https://github.com/aautar) for the PR! - -## [5.1.0] - 2016-09-29 ## -### Fixed -- Pull #295: [Upgrade sendgrid/php-http-client](https://github.com/sendgrid/sendgrid-php/pull/295/files) -- This adds getters for certain properties, please see [this pull request](https://github.com/sendgrid/php-http-client/pull/9) for details -- Thanks to [Arjan Keeman](https://github.com/akeeman) for the pull request! - -## [5.0.9] - 2016-09-13 ## -### Fixed -- Pull request #289: [Replace "\jsonSerializable" with "\JsonSerializable" ](https://github.com/sendgrid/sendgrid-php/pull/289) -- Thanks to [Issei.M](https://github.com/issei-m) for the pull request! - -## [5.0.8] - 2016-08-24 ## -### Added -- Table of Contents in the README -- Added a [USE_CASES.md](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md) section, with the first use case example for transactional templates - -## [5.0.7] - 2016-07-25 ## -### Added -- [Troubleshooting](https://github.com/sendgrid/sendgrid-php/blob/master/TROUBLESHOOTING.md) section - -## [5.0.6] - 2016-07-20 ## -### Added -- README updates -- Update introduction blurb to include information regarding our forward path -- Update the v3 /mail/send example to include non-helper usage -- Update the generic v3 example to include non-fluent interface usage - -## [5.0.5] - 2016-07-12 ## -### Added -- Update docs, unit tests and examples to include Sender ID - -## [5.0.4] - 2016-07-07 ## -### Added -- Tests now mocked automatically against [prism](https://stoplight.io/prism/) - -## [5.0.3] - 2016-07-05 ## -### Updated -- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) - -## [5.0.2] - 2016-07-05 ## -### Added -- Accept: application/json header per https://sendgrid.com/docs/API_Reference/Web_API_v3/How_To_Use_The_Web_API_v3/requests.html - -### Updated -- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) - -## [5.0.1] - 2016-06-17 ## -### Fixed -- Issue with packaged version for non-composer uses - -## [5.0.0] - 2016-06-13 ## -### Added -- Breaking change to support the v3 Web API -- New HTTP client -- v3 Mail Send helper - -## [v4.0.4] - (2016-02-18) ## -### Added -- Ability to add scopes to API Keys endpoint [POST] - -## [v4.0.3] - (2016-02-18) ## -### Added -- API Keys endpoint [PUT] - -## [v4.0.2] - (2015-12-15) ## -### Added -- Tests for API Keys endpoint [POST, PATCH, DELETE] - -## [v4.0.1] - (2015-12-03) ## -### Fixed -- HTTP 406 Not Acceptable Errors [#177](https://github.com/sendgrid/sendgrid-php/issues/177) - -## [v4.0.0] - (2015-10-16) ## -### Added -- Added support for accessing the [SendGrid Web API v3 endpoints](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) -- Implemented part of the /api_keys, /groups and /suppressions endpoints - -## [v3.2.0] - (2015-05-13) ## - -### Added -- Specify Guzzle proxy via [#149](https://github.com/sendgrid/sendgrid-php/pull/149) -- Option to disable exception raising - -## [v3.1.0] - (2015-04-27) -### Added -- Support for API keys - -## [v3.0.0] - (2015-04-14) -### Fixed -- CC and BCC not working with SMTPAPI To - -### Changed -- **Breaking:** A `\SendGrid\Exception` is now raised when response is not 200 -- **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` -- The library now depends on Guzzle3 -- Major refactoring - -### Added -- **Breaking:** `send()` now returns an instance of `\SendGrid\Response` -- Numerous missing methods for new functionality -- `addSmtpapiTo` for using the SMTPAPI To - -## [v2.2.1] - (2014-01-29) -### Fixed -- Fix turn_off_ssl_verification option via [#123](https://github.com/sendgrid/sendgrid-php/pull/123) - -## [v2.2.0] - (2014-01-12) -### Changed -- Remove [Unirest](https://github.com/Mashape/unirest-php/) and replace with native cURL -- Add CHANGELOG.md diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md deleted file mode 100644 index 60a06c4..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md +++ /dev/null @@ -1,193 +0,0 @@ -Hello! Thank you for choosing to help contribute to one of the SendGrid open source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies. - -- [CLAs and CCLAs](#cla) -- [Roadmap & Milestones](#roadmap) -- [Feature Request](#feature_request) -- [Submit a Bug Report](#submit_a_bug_report) -- [Improvements to the Codebase](#improvements_to_the_codebase) -- [Understanding the Code Base](#understanding_the_codebase) -- [Testing](#testing) -- [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions) -- [Creating a Pull Request](#creating_a_pull_request) - -<a name="roadmap"></a> -We use [Milestones](https://github.com/sendgrid/sendgrid-php/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged. - -<a name="cla"></a> -## CLAs and CCLAs - -Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project. - -Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution. - -SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla). - -When you create a Pull Request, after a few seconds, a comment will appear with a link to the CLA. Click the link and fill out the brief form and then click the "I agree" button and you are all set. You will not be asked to re-sign the CLA unless we make a change. - -There are a few ways to contribute, which we'll enumerate below: - -<a name="feature_request"></a> -## Feature Request - -If you'd like to make a feature request, please read this section. - -The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions: - -- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests. -- Please be respectful and considerate of others when commenting on issues - -<a name="submit_a_bug_report"></a> -## Submit a Bug Report - -Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public. - -A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report. - -Before you decide to create a new issue, please try the following: - -1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post. -2. Update to the latest version of this code and check if issue has already been fixed -3. Copy and fill in the Bug Report Template we have provided below - -### Please use our Bug Report Template - -In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-php/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting. - -<a name="improvements_to_the_codebase"></a> -## Improvements to the Codebase - -We welcome direct contributions to the sendgrid-php code base. Thank you! - -### Development Environment ### - -#### Install and Run Locally #### - -##### Prerequisites ##### - -- PHP 5.6 or 7.0 - -##### Initial setup: ##### - -```bash -git clone https://github.com/sendgrid/sendgrid-php.git -cd sendgrid-php -composer install -``` - -## Environment Variables - -First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-php). - -Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys). - -```bash -echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env -echo "sendgrid.env" >> .gitignore -source ./sendgrid.env -``` - -##### Execute: ##### - -See the [examples folder](https://github.com/sendgrid/sendgrid-php/tree/master/examples) to get started quickly. - -If you are using composer, replace <PATH_TO> with the path to your `vendor/autoload.php`. Otherwise, include lib/loader.php. - -<a name="understanding_the_codebase"></a> -## Understanding the Code Base - -**/examples** - -Working examples that demonstrate usage. - -```bash -php examples/example.php -``` - -**/test/unit** - -Unit tests for the HTTP client. - -**/lib** - -The interface to the SendGrid API. - -<a name="testing"></a> -## Testing - -All PRs require passing tests before the PR will be reviewed. - -All test files are in the [`/test/unit`](https://github.com/sendgrid/sendgrid-php/tree/master/test/unit) directory. - -For the purposes of contributing to this repo, please update the [`SendGridTest.php`](https://github.com/sendgrid/sendgrid-php/tree/master/test/unit/SendGridTest.php) file with unit tests as you modify the code. - -```bash -composer install -cd test/unit -../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test* -``` - -<a name="style_guidelines_and_naming_conventions"></a> -## Style Guidelines & Naming Conventions - -Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning. - -- [PSR2 Coding Standards](http://www.php-fig.org/psr/psr-2/) - -Please run your code through: - -- [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) - -## Creating a Pull Request<a name="creating_a_pull_request"></a> - -1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, - and configure the remotes: - - ```bash - # Clone your fork of the repo into the current directory - git clone https://github.com/sendgrid/sendgrid-php - # Navigate to the newly cloned directory - cd sendgrid-php - # Assign the original repo to a remote called "upstream" - git remote add upstream https://github.com/sendgrid/sendgrid-php - ``` - -2. If you cloned a while ago, get the latest changes from upstream: - - ```bash - git checkout <dev-branch> - git pull upstream <dev-branch> - ``` - -3. Create a new topic branch (off the main project development branch) to - contain your feature, change, or fix: - - ```bash - git checkout -b <topic-branch-name> - ``` - -4. Commit your changes in logical chunks. Please adhere to these [git commit - message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) - or your code is unlikely be merged into the main project. Use Git's - [interactive rebase](https://help.github.com/articles/interactive-rebase) - feature to tidy up your commits before making them public. - -4a. Create tests. - -4b. Create or update the example code that demonstrates the functionality of this change to the code. - -5. Locally merge (or rebase) the upstream development branch into your topic branch: - - ```bash - git pull [--rebase] upstream master - ``` - -6. Push your topic branch up to your fork: - - ```bash - git push origin <topic-branch-name> - ``` - -7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) - with a clear title and description against the `master` branch. All tests must be passing before we will review the PR. - -If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.txt b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.txt deleted file mode 100644 index 7f9d537..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2012-2016 SendGrid, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/README.md index 2add305..79d38ee 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/README.md +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/README.md @@ -1,208 +1,201 @@ +![SendGrid Logo](https://github.com/sendgrid/sendgrid-python/raw/master/twilio_sendgrid_logo.png) + [![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-php.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-php) +[![Packagist](https://img.shields.io/packagist/v/sendgrid/sendgrid.svg)](https://packagist.org/packages/sendgrid/sendgrid) +[![Downloads](https://img.shields.io/packagist/dt/sendgrid/sendgrid.svg?maxAge=3600)](https://packagist.org/packages/sendgrid/sendgrid) +[![Email Notifications Badge](https://dx.sendgrid.com/badge/php)](https://dx.sendgrid.com/newsletter/php) +[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md) +[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid) +[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-php.svg)](https://github.com/sendgrid/sendgrid-php/graphs/contributors) +[![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-php/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-php) -Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-php/issues/290). Your support is appreciated! +**NEW:** +- Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/php) for releases and breaking changes. +- Send SMS messages with [Twilio](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md#sms). -**This library allows you to quickly and easily use the SendGrid Web API v3 via PHP.** +**This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP.** -Version 5.X.X of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint). +Version 7.X.X of this library provides full support for all Twilio SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint). -This library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-php/issues) and [pull requests](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests. +We want this library to be community driven and Twilio SendGrid led. Your help is needed to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-php/issues) and [pull requests](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests. -Please browse the rest of this README for further detail. +Please browse the rest of this README for further details. We appreciate your continued support, thank you! # Table of Contents * [Installation](#installation) -* [Quick Start](#quick_start) +* [Quick Start](#quick-start) +* [Use Cases](#use-cases) * [Usage](#usage) -* [Use Cases](#use_cases) * [Announcements](#announcements) * [Roadmap](#roadmap) * [How to Contribute](#contribute) * [Troubleshooting](#troubleshooting) * [About](#about) +* [License](#license) <a name="installation"></a> # Installation ## Prerequisites -- PHP version 5.6 or 7.0 -- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php) +- PHP version 5.6, 7.0, 7.1 or 7.2 +- The Twilio SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php) to send up to 40,000 emails for the first 30 days, then send 100 emails/day free forever or check out [our pricing](https://sendgrid.com/pricing?source=sendgrid-php). +- For SMS messages, you will need a free [Twilio account](https://www.twilio.com/try-twilio?source=sendgrid-php). ## Setup Environment Variables Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example: +1. Copy the sample env file to a new file named `.env` +```bash +cp .env.sample .env +``` +2. Edit the `.env` file to include your `SENDGRID_API_KEY` +3. Source the `.env` file ```bash -echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env -echo "sendgrid.env" >> .gitignore -source ./sendgrid.env +source ./.env ``` ## Install Package -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. +Add Twilio SendGrid to your `composer.json` file. If you are not using [Composer](http://getcomposer.org), we highly recommend it. It's an excellent way to manage dependencies in your PHP application. ```json { "require": { - "sendgrid/sendgrid": "~6.0" + "sendgrid/sendgrid": "~7" } } ``` #### Alternative: Install package from zip -If you are not using Composer, simply download and install the **[latest packaged release of the library as a zip](https://github.com/sendgrid/sendgrid-php/archive/master.zip)**. +If you are not using Composer, simply download and install the **[latest packaged release of the library as a zip](https://github.com/sendgrid/sendgrid-php/releases/download/v7.3.0/sendgrid-php.zip)**. -[**⬇︎ Download Packaged Library ⬇︎**](https://github.com/sendgrid/sendgrid-php/archive/master.zip) +[**⬇︎ Download Packaged Library ⬇︎**](https://github.com/sendgrid/sendgrid-php/releases/download/v7.3.0/sendgrid-php.zip) -Previous versions of the library can be found in the [version index](https://sendgrid-open-source.s3.amazonaws.com/index.html) or downloaded directly from GitHub. +Previous versions of the library can be found in the [version index](https://sendgrid-open-source.s3.amazonaws.com/index.html) or downloaded directly from [GitHub](https://github.com/sendgrid/sendgrid-php/releases). ## Dependencies -- The SendGrid Service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php) -- [php-HTTP-Client](https://github.com/sendgrid/php-http-client) +- The Twilio SendGrid Service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php) +- The dependency free [php-http-client](https://github.com/sendgrid/php-http-client) -<a name="quick_start"></a> +<a name="quick-start"></a> # Quick Start ## Hello Email -The following is the minimum needed code to send an email with the [/mail/send Helper](https://github.com/sendgrid/sendgrid-php/tree/master/lib/helpers/mail) ([here](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/mail/example.php#L22) is a full example): +The following is the minimum needed code to send an email. You may find more examples in our USE_CASES file: ```php <?php -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$from = new SendGrid\Email("Example User", "test@example.com"); -$subject = "Sending with SendGrid is Fun"; -$to = new SendGrid\Email("Example User", "test@example.com"); -$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP"); -$mail = new SendGrid\Mail($from, $subject, $to, $content); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -$response = $sg->client->mail()->send()->post($mail); -echo $response->statusCode(); -print_r($response->headers()); -echo $response->body(); +require 'vendor/autoload.php'; // If you're using Composer (recommended) +// Comment out the above line if not using Composer +// require("<PATH TO>/sendgrid-php.php"); +// If not using Composer, uncomment the above line and +// download sendgrid-php.zip from the latest release here, +// replacing <PATH TO> with the path to the sendgrid-php.php file, +// which is included in the download: +// https://github.com/sendgrid/sendgrid-php/releases + +$email = new \SendGrid\Mail\Mail(); +$email->setFrom("test@example.com", "Example User"); +$email->setSubject("Sending with Twilio SendGrid is Fun"); +$email->addTo("test@example.com", "Example User"); +$email->addContent("text/plain", "and easy to do anywhere, even with PHP"); +$email->addContent( + "text/html", "<strong>and easy to do anywhere, even with PHP</strong>" +); +$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY')); +try { + $response = $sendgrid->send($email); + print $response->statusCode() . "\n"; + print_r($response->headers()); + print $response->body() . "\n"; +} catch (Exception $e) { + echo 'Caught exception: '. $e->getMessage() ."\n"; +} ``` -The `SendGrid\Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/mail/example.php#L16) is an example of how to add to it. - -### Without Mail Helper Class - -The following is the minimum needed code to send an email without the /mail/send Helper ([here](https://github.com/sendgrid/sendgrid-php/blob/master/examples/mail/mail.php#L28) is a full example): - -```php -<?php -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$request_body = json_decode('{ - "personalizations": [ - { - "to": [ - { - "email": "test@example.com" - } - ], - "subject": "Sending with SendGrid is Fun" - } - ], - "from": { - "email": "test@example.com" - }, - "content": [ - { - "type": "text/plain", - "value": "and easy to do anywhere, even with PHP" - } - ] -}'); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -$response = $sg->client->mail()->send()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` +The `SendGrid\Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md#kitchen-sink) is an example of how to add to it. ## General v3 Web API Usage (With Fluent Interface) ```php <?php -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); +require 'vendor/autoload.php'; // If you're using Composer (recommended) +// Comment out the above line if not using Composer +// Comment out the above line if not using Composer +// require("<PATH TO>/sendgrid-php.php"); +// If not using Composer, uncomment the above line and +// download sendgrid-php.zip from the latest release here, +// replacing <PATH TO> with the path to the sendgrid-php.php file, +// which is included in the download: +// https://github.com/sendgrid/sendgrid-php/releases $apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey); -$response = $sg->client->suppression()->bounces()->get(); - -print $response->statusCode(); -print $response->headers(); -print $response->body(); +try { + $response = $sg->client->suppression()->bounces()->get(); + print $response->statusCode() . "\n"; + print_r($response->headers()); + print $response->body() . "\n"; +} catch (Exception $e) { + echo 'Caught exception: '. $e->getMessage(). "\n"; +} ``` ## General v3 Web API Usage (Without Fluent Interface) ```php <?php -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); +require 'vendor/autoload.php'; // If you're using Composer (recommended) +// Comment out the above line if not using Composer +// Comment out the above line if not using Composer +// require("<PATH TO>/sendgrid-php.php"); +// If not using Composer, uncomment the above line and +// download sendgrid-php.zip from the latest release here, +// replacing <PATH TO> with the path to the sendgrid-php.php file, +// which is included in the download: +// https://github.com/sendgrid/sendgrid-php/releases $apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey); -$response = $sg->client->_("suppression/bounces")->get(); - -print $response->statusCode(); -print $response->headers(); -print $response->body(); +try { + $response = $sg->client->_("suppression/bounces")->get(); + print $response->statusCode() . "\n"; + print_r($response->headers()); + print $response->body() . "\n"; +} catch (Exception $e) { + echo 'Caught exception: '. $e->getMessage(). "\n"; +} ``` +<a name="use-cases"></a> +# Use Cases + +[Examples of common API use cases](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md), such as how to send an email with a transactional template. + <a name="usage"></a> # Usage -- [SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html) -- [Library Usage +- [Twilio SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html) +- [Generic Library Usage Documentation](https://github.com/sendgrid/sendgrid-php/tree/master/USAGE.md) -- [Example Code](https://github.com/sendgrid/sendgrid-php/tree/master/examples) -- [How-to: Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) -- [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-php/tree/master/lib/helpers/mail/README.md) - build a request object payload for a v3 /mail/send API call. - -<a name="use_cases"> -# Use Cases - -[Examples of common API use cases](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md), such as how to send an email with a transactional template. +- [Example Code](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md) <a name="announcements"></a> # Announcements -Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-php/issues/290). Your support is appreciated! +v7 has been released! Please see the [release notes](https://github.com/sendgrid/sendgrid-php/releases/tag/v7.0.0) for details. -All updates to this library is documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-php/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-php/releases) +All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-php/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-php/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/php) for releases and breaking changes. <a name="roadmap"></a> # Roadmap @@ -220,6 +213,7 @@ Quick links: - [Bug Reports](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md#submit_a_bug_report) - [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md#cla) - [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md#improvements_to_the_codebase) +- [Review Pull Requests](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md#code-reviews) <a name="troubleshooting"></a> # Troubleshooting @@ -229,9 +223,10 @@ Please see our [troubleshooting guide](https://github.com/sendgrid/sendgrid-php/ <a name="about"></a> # About -sendgrid-php is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com). +sendgrid-php is guided and supported by the Twilio [Developer Experience Team](mailto:dx@sendgrid.com). -sendgrid-php is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-php are trademarks of SendGrid, Inc. +sendgrid-php is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-php are trademarks of Twilio SendGrid, Inc. -![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) +# License +[The MIT License (MIT)](LICENSE.txt) diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md deleted file mode 100644 index ec0a293..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md +++ /dev/null @@ -1,89 +0,0 @@ -If you have a non-library SendGrid issue, please contact our [support team](https://support.sendgrid.com). - -If you can't find a solution below, please open an [issue](https://github.com/sendgrid/sendgrid-php/issues). - - -## Table of Contents - -* [Migrating from v2 to v3](#migrating) -* [Continue Using v2](#v2) -* [Testing v3 /mail/send Calls Directly](#testing) -* [Error Messages](#error) -* [Versions](#versions) -* [Environment Variables and Your SendGrid API Key](#environment) -* [Using the Package Manager](#package-manager) - -<a name="migrating"></a> -## Migrating from v2 to v3 - -Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) on how to migrate from v2 to v3. - -<a name="v2"></a> -## Continue Using v2 - -[Here](https://github.com/sendgrid/sendgrid-php/tree/75970eb82f5629e66db4d6da08ff7ef0c507e9b0) is the last working version with v2 support. - -Using composer: - -```json -{ - "require": { - "sendgrid/sendgrid": "~3.2" - } -} -``` - -Download packaged zip [here](https://sendgrid-open-source.s3.amazonaws.com/sendgrid-php/versions/sendgrid-php-75970eb.zip). - -<a name="testing"></a> -## Testing v3 /mail/send Calls Directly - -[Here](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/curl_examples.html) are some cURL examples for common use cases. - -<a name="error"></a> -## Error Messages - -To read the error message returned by SendGrid's API: - -```php -try { - $response = $sendgrid->client->mail()->send()->post($mail); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} -``` - -<a name="versions"></a> -## Versions - -We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guarenteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-php/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-php/releases) section. - -<a name="environment"></a> -## Environment Variables and Your SendGrid API Key - -All of our examples assume you are using [environment variables](https://github.com/sendgrid/sendgrid-php#setup-environment-variables) to hold your SendGrid API key. - -If you choose to add your SendGrid API key directly (not recommended): - -`$apiKey = getenv('SENDGRID_API_KEY');` - -becomes - -`$apiKey = 'SENDGRID_API_KEY';` - -In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key. - -<a name="package-manager"></a> -## Using the Package Manager - -We upload this library to [Packagist](https://packagist.org/packages/sendgrid/sendgrid) whenever we make a release. This allows you to use [composer](https://getcomposer.org) for easy installation. - -In most cases we recommend you download the latest version of the library, but if you need a different version, please use: - -```json -{ - "require": { - "sendgrid/sendgrid": "~X.X.X" - } -} -```
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md deleted file mode 100644 index 00a0d0d..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md +++ /dev/null @@ -1,5038 +0,0 @@ -This documentation is based on our [OAI specification](https://github.com/sendgrid/sendgrid-oai). - -# INITIALIZATION - -```php -// If you are using Composer -require 'vendor/autoload.php'; - - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); -``` - -# Table of Contents - -* [ACCESS SETTINGS](#access_settings) -* [ALERTS](#alerts) -* [API KEYS](#api_keys) -* [ASM](#asm) -* [BROWSERS](#browsers) -* [CAMPAIGNS](#campaigns) -* [CATEGORIES](#categories) -* [CLIENTS](#clients) -* [CONTACTDB](#contactdb) -* [DEVICES](#devices) -* [GEO](#geo) -* [IPS](#ips) -* [MAIL](#mail) -* [MAIL SETTINGS](#mail_settings) -* [MAILBOX PROVIDERS](#mailbox_providers) -* [PARTNER SETTINGS](#partner_settings) -* [SCOPES](#scopes) -* [SENDERS](#senders) -* [STATS](#stats) -* [SUBUSERS](#subusers) -* [SUPPRESSION](#suppression) -* [TEMPLATES](#templates) -* [TRACKING SETTINGS](#tracking_settings) -* [USER](#user) -* [WHITELABEL](#whitelabel) - - -<a name="access_settings"></a> -# ACCESS SETTINGS - -## Retrieve all recent access attempts - -**This endpoint allows you to retrieve a list of all of the IP addresses that recently attempted to access your account either through the User Interface or the API.** - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/activity - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->access_settings()->activity()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add one or more IPs to the whitelist - -**This endpoint allows you to add one or more IP addresses to your IP whitelist.** - -When adding an IP to your whitelist, include the IP address in an array. You can whitelist one IP at a time, or you can whitelist multiple IPs at once. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### POST /access_settings/whitelist - - -```php -$request_body = json_decode('{ - "ips": [ - { - "ip": "192.168.1.1" - }, - { - "ip": "192.*.*.*" - }, - { - "ip": "192.168.1.3/32" - } - ] -}'); -$response = $sg->client->access_settings()->whitelist()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a list of currently whitelisted IPs - -**This endpoint allows you to retrieve a list of IP addresses that are currently whitelisted.** - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/whitelist - - -```php -$response = $sg->client->access_settings()->whitelist()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove one or more IPs from the whitelist - -**This endpoint allows you to remove one or more IPs from your IP whitelist.** - -You can remove one IP at a time, or you can remove multiple IP addresses. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### DELETE /access_settings/whitelist - - -```php -$request_body = json_decode('{ - "ids": [ - 1, - 2, - 3 - ] -}'); -$response = $sg->client->access_settings()->whitelist()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific whitelisted IP - -**This endpoint allows you to retreive a specific IP address that has been whitelisted.** - -You must include the ID for the specific IP address you want to retrieve in your call. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/whitelist/{rule_id} - - -```php -$rule_id = "test_url_param"; -$response = $sg->client->access_settings()->whitelist()->_($rule_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove a specific IP from the whitelist - -**This endpoint allows you to remove a specific IP address from your IP whitelist.** - -When removing a specific IP address from your whitelist, you must include the ID in your call. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### DELETE /access_settings/whitelist/{rule_id} - - -```php -$rule_id = "test_url_param"; -$response = $sg->client->access_settings()->whitelist()->_($rule_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="alerts"></a> -# ALERTS - -## Create a new Alert - -**This endpoint allows you to create a new alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### POST /alerts - - -```php -$request_body = json_decode('{ - "email_to": "example@example.com", - "frequency": "daily", - "type": "stats_notification" -}'); -$response = $sg->client->alerts()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all alerts - -**This endpoint allows you to retieve all of your alerts.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### GET /alerts - - -```php -$response = $sg->client->alerts()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update an alert - -**This endpoint allows you to update an alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### PATCH /alerts/{alert_id} - - -```php -$request_body = json_decode('{ - "email_to": "example@example.com" -}'); -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific alert - -**This endpoint allows you to retrieve a specific alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### GET /alerts/{alert_id} - - -```php -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an alert - -**This endpoint allows you to delete an alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### DELETE /alerts/{alert_id} - - -```php -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="api_keys"></a> -# API KEYS - -## Create API keys - -**This enpoint allows you to create a new random API Key for the user.** - -A JSON request body containing a "name" property is required. If number of maximum keys is reached, HTTP 403 will be returned. - -There is a limit of 100 API Keys on your account. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -See the [API Key Permissions List](https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/api_key_permissions_list.html) for a list of all available scopes. - -### POST /api_keys - - -```php -$request_body = json_decode('{ - "name": "My API Key", - "sample": "data", - "scopes": [ - "mail.send", - "alerts.create", - "alerts.read" - ] -}'); -$response = $sg->client->api_keys()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all API Keys belonging to the authenticated user - -**This endpoint allows you to retrieve all API Keys that belong to the authenticated user.** - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -### GET /api_keys - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->api_keys()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update the name & scopes of an API Key - -**This endpoint allows you to update the name and scopes of a given API key.** - -A JSON request body with a "name" property is required. -Most provide the list of all the scopes an api key should have. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - - -### PUT /api_keys/{api_key_id} - - -```php -$request_body = json_decode('{ - "name": "A New Hope", - "scopes": [ - "user.profile.read", - "user.profile.update" - ] -}'); -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update API keys - -**This endpoint allows you to update the name of an existing API Key.** - -A JSON request body with a "name" property is required. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -## URI Parameters - -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -|api_key_id |string | required | The ID of the API Key you are updating.| - -### PATCH /api_keys/{api_key_id} - - -```php -$request_body = json_decode('{ - "name": "A New Hope" -}'); -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve an existing API Key - -**This endpoint allows you to retrieve a single api key.** - -If the API Key ID does not exist an HTTP 404 will be returned. - -### GET /api_keys/{api_key_id} - - -```php -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete API keys - -**This endpoint allows you to revoke an existing API Key** - -Authentications using this API Key will fail after this request is made, with some small propogation delay.If the API Key ID does not exist an HTTP 404 will be returned. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -## URI Parameters - -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -|api_key_id |string | required | The ID of the API Key you are deleting.| - -### DELETE /api_keys/{api_key_id} - - -```php -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="asm"></a> -# ASM - -## Create a new suppression group - -**This endpoint allows you to create a new suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### POST /asm/groups - - -```php -$request_body = json_decode('{ - "description": "Suggestions for products our users might like.", - "is_default": true, - "name": "Product Suggestions" -}'); -$response = $sg->client->asm()->groups()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve information about multiple suppression groups - -**This endpoint allows you to retrieve information about multiple suppression groups.** - -This endpoint will return information for each group ID that you include in your request. To add a group ID to your request, simply append `&id=` followed by the group ID. - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html), allow you to label a category of content that you regularly send. This gives your recipients the ability to opt out of a specific set of your email. For example, you might define a group for your transactional email, and one for your marketing email so that your users can continue recieving your transactional email witout having to receive your marketing content. - -### GET /asm/groups - - -```php -$query_params = json_decode('{"id": 1}'); -$response = $sg->client->asm()->groups()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a suppression group. - -**This endpoint allows you to update or change a suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### PATCH /asm/groups/{group_id} - - -```php -$request_body = json_decode('{ - "description": "Suggestions for items our users might like.", - "id": 103, - "name": "Item Suggestions" -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get information on a single suppression group. - -**This endpoint allows you to retrieve a single suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### GET /asm/groups/{group_id} - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a suppression group. - -**This endpoint allows you to delete a suppression group.** - -You can only delete groups that have not been attached to sent mail in the last 60 days. If a recipient uses the "one-click unsubscribe" option on an email associated with a deleted group, that recipient will be added to the global suppression list. - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### DELETE /asm/groups/{group_id} - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add suppressions to a suppression group - -**This endpoint allows you to add email addresses to an unsubscribe group.** - -If you attempt to add suppressions to a group that has been deleted or does not exist, the suppressions will be added to the global suppressions list. - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### POST /asm/groups/{group_id}/suppressions - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppressions for a suppression group - -**This endpoint allows you to retrieve all suppressed email addresses belonging to the given group.** - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### GET /asm/groups/{group_id}/suppressions - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Search for suppressions within a group - -**This endpoint allows you to search a suppression group for multiple suppressions.** - -When given a list of email addresses and a group ID, this endpoint will return only the email addresses that have been unsubscribed from the given group. - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### POST /asm/groups/{group_id}/suppressions/search - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "exists1@example.com", - "exists2@example.com", - "doesnotexists@example.com" - ] -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->search()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a suppression from a suppression group - -**This endpoint allows you to remove a suppressed email address from the given suppression group.** - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### DELETE /asm/groups/{group_id}/suppressions/{email} - - -```php -$group_id = "test_url_param"; -$email = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppressions - -**This endpoint allows you to retrieve a list of all suppressions.** - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### GET /asm/suppressions - - -```php -$response = $sg->client->asm()->suppressions()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add recipient addresses to the global suppression group. - -**This endpoint allows you to add one or more email addresses to the global suppressions group.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### POST /asm/suppressions/global - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] -}'); -$response = $sg->client->asm()->suppressions()->global()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Global Suppression - -**This endpoint allows you to retrieve a global suppression. You can also use this endpoint to confirm if an email address is already globally suppresed.** - -If the email address you include in the URL path parameter `{email}` is alreayd globally suppressed, the response will include that email address. If the address you enter for `{email}` is not globally suppressed, an empty JSON object `{}` will be returned. - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### GET /asm/suppressions/global/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->global()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Global Suppression - -**This endpoint allows you to remove an email address from the global suppressions group.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### DELETE /asm/suppressions/global/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->global()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppression groups for an email address - -**This endpoint returns the list of all groups that the given email address has been unsubscribed from.** - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### GET /asm/suppressions/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="browsers"></a> -# BROWSERS - -## Retrieve email statistics by browser. - -**This endpoint allows you to retrieve your email statistics segmented by browser type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /browsers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "browsers": "test_string", "limit": "test_string", "offset": "test_string", "start_date": "2016-01-01"}'); -$response = $sg->client->browsers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="campaigns"></a> -# CAMPAIGNS - -## Create a Campaign - -**This endpoint allows you to create a campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -Note: In order to send or schedule the campaign, you will be required to provide a subject, sender ID, content (we suggest both html and plain text), and at least one list or segment ID. This information is not required when you create a campaign. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns - - -```php -$request_body = json_decode('{ - "categories": [ - "spring line" - ], - "custom_unsubscribe_url": "", - "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>", - "ip_pool": "marketing", - "list_ids": [ - 110, - 124 - ], - "plain_content": "Check out our spring line!", - "segment_ids": [ - 110 - ], - "sender_id": 124451, - "subject": "New Products for Spring!", - "suppression_group_id": 42, - "title": "March Newsletter" -}'); -$response = $sg->client->campaigns()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all Campaigns - -**This endpoint allows you to retrieve a list of all of your campaigns.** - -Returns campaigns in reverse order they were created (newest first). - -Returns an empty array if no campaigns exist. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->campaigns()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Campaign - -Update a campaign. This is especially useful if you only set up the campaign using POST /campaigns, but didn't set many of the parameters. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### PATCH /campaigns/{campaign_id} - - -```php -$request_body = json_decode('{ - "categories": [ - "summer line" - ], - "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>", - "plain_content": "Check out our summer line!", - "subject": "New Products for Summer!", - "title": "May Newsletter" -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single campaign - -**This endpoint allows you to retrieve a specific campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns/{campaign_id} - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Campaign - -**This endpoint allows you to delete a specific campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### DELETE /campaigns/{campaign_id} - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Scheduled Campaign - -**This endpoint allows to you change the scheduled time and date for a campaign to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### PATCH /campaigns/{campaign_id}/schedules - - -```php -$request_body = json_decode('{ - "send_at": 1489451436 -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Schedule a Campaign - -**This endpoint allows you to schedule a specific date and time for your campaign to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules - - -```php -$request_body = json_decode('{ - "send_at": 1489771528 -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## View Scheduled Time of a Campaign - -**This endpoint allows you to retrieve the date and time that the given campaign has been scheduled to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns/{campaign_id}/schedules - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Unschedule a Scheduled Campaign - -**This endpoint allows you to unschedule a campaign that has already been scheduled to be sent.** - -A successful unschedule will return a 204. -If the specified campaign is in the process of being sent, the only option is to cancel (a different method). - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### DELETE /campaigns/{campaign_id}/schedules - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Send a Campaign - -**This endpoint allows you to immediately send a campaign at the time you make the API call.** - -Normally a POST would have a request body, but since this endpoint is telling us to send a resource that is already created, a request body is not needed. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules/now - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->now()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Send a Test Campaign - -**This endpoint allows you to send a test campaign.** - -To send to multiple addresses, use an array for the JSON "to" value ["one@address","two@address"] - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules/test - - -```php -$request_body = json_decode('{ - "to": "your.email@example.com" -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->test()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="categories"></a> -# CATEGORIES - -## Retrieve all categories - -**This endpoint allows you to retrieve a list of all of your categories.** - -Categories can help organize your email analytics by enabling you to tag emails by type or broad topic. You can define your own custom categories. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories - - -```php -$query_params = json_decode('{"category": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->categories()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Email Statistics for Categories - -**This endpoint allows you to retrieve all of your email statistics for each of your categories.** - -If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10. - -Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}'); -$response = $sg->client->categories()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] - -**This endpoint allows you to retrieve the total sum of each email statistic for every category over the given date range.** - -If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10. - -Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories/stats/sums - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); -$response = $sg->client->categories()->stats()->sums()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="clients"></a> -# CLIENTS - -## Retrieve email statistics by client type. - -**This endpoint allows you to retrieve your email statistics segmented by client type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /clients/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); -$response = $sg->client->clients()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve stats by a specific client type. - -**This endpoint allows you to retrieve your email statistics segmented by a specific client type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -## Available Client Types -- phone -- tablet -- webmail -- desktop - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /clients/{client_type}/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); -$client_type = "test_url_param"; -$response = $sg->client->clients()->_($client_type)->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="contactdb"></a> -# CONTACTDB - -## Create a Custom Field - -**This endpoint allows you to create a custom field.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### POST /contactdb/custom_fields - - -```php -$request_body = json_decode('{ - "name": "pet", - "type": "text" -}'); -$response = $sg->client->contactdb()->custom_fields()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all custom fields - -**This endpoint allows you to retrieve all custom fields.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/custom_fields - - -```php -$response = $sg->client->contactdb()->custom_fields()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Custom Field - -**This endpoint allows you to retrieve a custom field by ID.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/custom_fields/{custom_field_id} - - -```php -$custom_field_id = "test_url_param"; -$response = $sg->client->contactdb()->custom_fields()->_($custom_field_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Custom Field - -**This endpoint allows you to delete a custom field by ID.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### DELETE /contactdb/custom_fields/{custom_field_id} - - -```php -$custom_field_id = "test_url_param"; -$response = $sg->client->contactdb()->custom_fields()->_($custom_field_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a List - -**This endpoint allows you to create a list for your recipients.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists - - -```php -$request_body = json_decode('{ - "name": "your list name" -}'); -$response = $sg->client->contactdb()->lists()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all lists - -**This endpoint allows you to retrieve all of your recipient lists. If you don't have any lists, an empty array will be returned.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists - - -```php -$response = $sg->client->contactdb()->lists()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete Multiple lists - -**This endpoint allows you to delete multiple recipient lists.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists - - -```php -$request_body = json_decode('[ - 1, - 2, - 3, - 4 -]'); -$response = $sg->client->contactdb()->lists()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a List - -**This endpoint allows you to update the name of one of your recipient lists.** - - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### PATCH /contactdb/lists/{list_id} - - -```php -$request_body = json_decode('{ - "name": "newlistname" -}'); -$query_params = json_decode('{"list_id": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->patch($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single list - -This endpoint allows you to retrieve a single recipient list. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists/{list_id} - - -```php -$query_params = json_decode('{"list_id": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a List - -**This endpoint allows you to delete a specific recipient list with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists/{list_id} - - -```php -$query_params = json_decode('{"delete_contacts": "true"}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add Multiple Recipients to a List - -**This endpoint allows you to add multiple recipients to a list.** - -Adds existing recipients to a list, passing in the recipient IDs to add. Recipient IDs should be passed exactly as they are returned from recipient endpoints. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists/{list_id}/recipients - - -```php -$request_body = json_decode('[ - "recipient_id1", - "recipient_id2" -]'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all recipients on a List - -**This endpoint allows you to retrieve all recipients on the list with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists/{list_id}/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add a Single Recipient to a List - -**This endpoint allows you to add a single recipient to a list.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists/{list_id}/recipients/{recipient_id} - - -```php -$list_id = "test_url_param"; -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->_($recipient_id)->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Single Recipient from a Single List - -**This endpoint allows you to delete a single recipient from a list.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} - - -```php -$query_params = json_decode('{"recipient_id": 1, "list_id": 1}'); -$list_id = "test_url_param"; -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->_($recipient_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Recipient - -**This endpoint allows you to update one or more recipients.** - -The body of an API call to this endpoint must include an array of one or more recipient objects. - -It is of note that you can add custom field data as parameters on recipient objects. We have provided an example using some of the default custom fields SendGrid provides. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### PATCH /contactdb/recipients - - -```php -$request_body = json_decode('[ - { - "email": "jones@example.com", - "first_name": "Guy", - "last_name": "Jones" - } -]'); -$response = $sg->client->contactdb()->recipients()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add recipients - -**This endpoint allows you to add a Marketing Campaigns recipient.** - -It is of note that you can add custom field data as a parameter on this endpoint. We have provided an example using some of the default custom fields SendGrid provides. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/recipients - - -```php -$request_body = json_decode('[ - { - "age": 25, - "email": "example@example.com", - "first_name": "", - "last_name": "User" - }, - { - "age": 25, - "email": "example2@example.com", - "first_name": "Example", - "last_name": "User" - } -]'); -$response = $sg->client->contactdb()->recipients()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients - -**This endpoint allows you to retrieve all of your Marketing Campaigns recipients.** - -Batch deletion of a page makes it possible to receive an empty page of recipients before reaching the end of -the list of recipients. To avoid this issue; iterate over pages until a 404 is retrieved. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$response = $sg->client->contactdb()->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete Recipient - -**This endpoint allows you to deletes one or more recipients.** - -The body of an API call to this endpoint must include an array of recipient IDs of the recipients you want to delete. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### DELETE /contactdb/recipients - - -```php -$request_body = json_decode('[ - "recipient_id1", - "recipient_id2" -]'); -$response = $sg->client->contactdb()->recipients()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the count of billable recipients - -**This endpoint allows you to retrieve the number of Marketing Campaigns recipients that you will be billed for.** - -You are billed for marketing campaigns based on the highest number of recipients you have had in your account at one time. This endpoint will allow you to know the current billable count value. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/billable_count - - -```php -$response = $sg->client->contactdb()->recipients()->billable_count()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Count of Recipients - -**This endpoint allows you to retrieve the total number of Marketing Campaigns recipients.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/recipients/count - - -```php -$response = $sg->client->contactdb()->recipients()->count()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients matching search criteria - -**This endpoint allows you to perform a search on all of your Marketing Campaigns recipients.** - -field_name: - -* is a variable that is substituted for your actual custom field name from your recipient. -* Text fields must be url-encoded. Date fields are searchable only by unix timestamp (e.g. 2/2/2015 becomes 1422835200) -* If field_name is a 'reserved' date field, such as created_at or updated_at, the system will internally convert -your epoch time to a date range encompassing the entire day. For example, an epoch time of 1422835600 converts to -Mon, 02 Feb 2015 00:06:40 GMT, but internally the system will search from Mon, 02 Feb 2015 00:00:00 GMT through -Mon, 02 Feb 2015 23:59:59 GMT. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/recipients/search - - -```php -$query_params = json_decode('{"{field_name}": "test_string"}'); -$response = $sg->client->contactdb()->recipients()->search()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single recipient - -**This endpoint allows you to retrieve a single recipient by ID from your contact database.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/{recipient_id} - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Recipient - -**This endpoint allows you to delete a single recipient with the given ID from your contact database.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/recipients/{recipient_id} - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the lists that a recipient is on - -**This endpoint allows you to retrieve the lists that a given recipient belongs to.** - -Each recipient can be on many lists. This endpoint gives you all of the lists that any one recipient has been added to. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/{recipient_id}/lists - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->lists()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve reserved fields - -**This endpoint allows you to list all fields that are reserved and can't be used for custom field names.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/reserved_fields - - -```php -$response = $sg->client->contactdb()->reserved_fields()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a Segment - -**This endpoint allows you to create a segment.** - -All recipients in your contactdb will be added or removed automatically depending on whether they match the criteria for this segment. - -List Id: - -* Send this to segment from an existing list -* Don't send this in order to segment from your entire contactdb. - -Valid operators for create and update depend on the type of the field you are segmenting: - -* **Dates:** "eq", "ne", "lt" (before), "gt" (after) -* **Text:** "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value) -* **Numbers:** "eq", "lt", "gt" -* **Email Clicks and Opens:** "eq" (opened), "ne" (not opened) - -Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign. - -Segments may contain multiple condtions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or". - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### POST /contactdb/segments - - -```php -$request_body = json_decode('{ - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - }, - { - "and_or": "and", - "field": "last_clicked", - "operator": "gt", - "value": "01/02/2015" - }, - { - "and_or": "or", - "field": "clicks.campaign_identifier", - "operator": "eq", - "value": "513" - } - ], - "list_id": 4, - "name": "Last Name Miller" -}'); -$response = $sg->client->contactdb()->segments()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all segments - -**This endpoint allows you to retrieve all of your segments.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments - - -```php -$response = $sg->client->contactdb()->segments()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a segment - -**This endpoint allows you to update a segment.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### PATCH /contactdb/segments/{segment_id} - - -```php -$request_body = json_decode('{ - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - } - ], - "list_id": 5, - "name": "The Millers" -}'); -$query_params = json_decode('{"segment_id": "test_string"}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->patch($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a segment - -**This endpoint allows you to retrieve a single segment with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments/{segment_id} - - -```php -$query_params = json_decode('{"segment_id": 1}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a segment - -**This endpoint allows you to delete a segment from your recipients database.** - -You also have the option to delete all the contacts from your Marketing Campaigns recipient database who were in this segment. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### DELETE /contactdb/segments/{segment_id} - - -```php -$query_params = json_decode('{"delete_contacts": "true"}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients on a segment - -**This endpoint allows you to retrieve all of the recipients in a segment with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments/{segment_id}/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="devices"></a> -# DEVICES - -## Retrieve email statistics by device type. - -**This endpoint allows you to retrieve your email statistics segmented by the device type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -## Available Device Types -| **Device** | **Description** | **Example** | -|---|---|---| -| Desktop | Email software on desktop computer. | I.E., Outlook, Sparrow, or Apple Mail. | -| Webmail | A web-based email client. | I.E., Yahoo, Google, AOL, or Outlook.com. | -| Phone | A smart phone. | iPhone, Android, Blackberry, etc. -| Tablet | A tablet computer. | iPad, android based tablet, etc. | -| Other | An unrecognized device. | - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /devices/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); -$response = $sg->client->devices()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="geo"></a> -# GEO - -## Retrieve email statistics by country and state/province. - -**This endpoint allows you to retrieve your email statistics segmented by country and state/province.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /geo/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "country": "US", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); -$response = $sg->client->geo()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="ips"></a> -# IPS - -## Retrieve all IP addresses - -**This endpoint allows you to retrieve a list of all assigned and unassigned IPs.** - -Response includes warm up status, pools, assigned subusers, and whitelabel info. The start_date field corresponds to when warmup started for that IP. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips - - -```php -$query_params = json_decode('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}'); -$response = $sg->client->ips()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all assigned IPs - -**This endpoint allows you to retrieve only assigned IP addresses.** - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips/assigned - - -```php -$response = $sg->client->ips()->assigned()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create an IP pool. - -**This endpoint allows you to create an IP pool.** - -**Each user can create up to 10 different IP pools.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### POST /ips/pools - - -```php -$request_body = json_decode('{ - "name": "marketing" -}'); -$response = $sg->client->ips()->pools()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP pools. - -**This endpoint allows you to retreive all of your IP pools.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### GET /ips/pools - - -```php -$response = $sg->client->ips()->pools()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update an IP pools name. - -**This endpoint allows you to update the name of an IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### PUT /ips/pools/{pool_name} - - -```php -$request_body = json_decode('{ - "name": "new_pool_name" -}'); -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IPs in a specified pool. - -**This endpoint allows you to list all of the IP addresses that are in a specific IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### GET /ips/pools/{pool_name} - - -```php -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an IP pool. - -**This endpoint allows you to delete an IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### DELETE /ips/pools/{pool_name} - - -```php -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP address to a pool - -**This endpoint allows you to add an IP address to an IP pool.** - -You can add the same IP address to multiple pools. It may take up to 60 seconds for your IP address to be added to a pool after your request is made. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### POST /ips/pools/{pool_name}/ips - - -```php -$request_body = json_decode('{ - "ip": "0.0.0.0" -}'); -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP address from a pool. - -**This endpoint allows you to remove an IP address from an IP pool.** - -The same IP address can be added to multiple IP pools. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### DELETE /ips/pools/{pool_name}/ips/{ip} - - -```php -$pool_name = "test_url_param"; -$ip = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->ips()->_($ip)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP to warmup - -**This endpoint allows you to enter an IP address into warmup mode.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### POST /ips/warmup - - -```php -$request_body = json_decode('{ - "ip": "0.0.0.0" -}'); -$response = $sg->client->ips()->warmup()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IPs currently in warmup - -**This endpoint allows you to retrieve all of your IP addresses that are currently warming up.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### GET /ips/warmup - - -```php -$response = $sg->client->ips()->warmup()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve warmup status for a specific IP address - -**This endpoint allows you to retrieve the warmup status for a specific IP address.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### GET /ips/warmup/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->warmup()->_($ip_address)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP from warmup - -**This endpoint allows you to remove an IP address from warmup mode.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### DELETE /ips/warmup/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->warmup()->_($ip_address)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP pools an IP address belongs to - -**This endpoint allows you to see which IP pools a particular IP address has been added to.** - -The same IP address can be added to multiple IP pools. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->_($ip_address)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mail"></a> -# MAIL - -## Create a batch ID - -**This endpoint allows you to generate a new batch ID. This batch ID can be associated with scheduled sends via the mail/send endpoint.** - -If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint. - -More Information: - -* [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) - -### POST /mail/batch - - -```php -$response = $sg->client->mail()->batch()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate batch ID - -**This endpoint allows you to validate a batch ID.** - -If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint. - -More Information: - -* [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) - -### GET /mail/batch/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->mail()->batch()->_($batch_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## v3 Mail Send - -This endpoint allows you to send email over SendGrids v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, please see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -* Top level parameters are referred to as "global". -* Individual fields within the personalizations array will override any other global, or message level, parameters that are defined outside of personalizations. - -For an overview of the v3 Mail Send endpoint, please visit our [v3 API Reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html) - -For more detailed information about how to use the v3 Mail Send endpoint, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html). - -### POST /mail/send - -This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-php/blob/master/lib/helpers/mail/README.md). - -```php -$request_body = json_decode('{ - "asm": { - "group_id": 1, - "groups_to_display": [ - 1, - 2, - 3 - ] - }, - "attachments": [ - { - "content": "[BASE64 encoded content block here]", - "content_id": "ii_139db99fdb5c3704", - "disposition": "inline", - "filename": "file1.jpg", - "name": "file1", - "type": "jpg" - } - ], - "batch_id": "[YOUR BATCH ID GOES HERE]", - "categories": [ - "category1", - "category2" - ], - "content": [ - { - "type": "text/html", - "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>" - } - ], - "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", - "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, - "from": { - "email": "sam.smith@example.com", - "name": "Sam Smith" - }, - "headers": {}, - "ip_pool_name": "[YOUR POOL NAME GOES HERE]", - "mail_settings": { - "bcc": { - "email": "ben.doe@example.com", - "enable": true - }, - "bypass_list_management": { - "enable": true - }, - "footer": { - "enable": true, - "html": "<p>Thanks</br>The SendGrid Team</p>", - "text": "Thanks,/n The SendGrid Team" - }, - "sandbox_mode": { - "enable": false - }, - "spam_check": { - "enable": true, - "post_to_url": "http://example.com/compliance", - "threshold": 3 - } - }, - "personalizations": [ - { - "bcc": [ - { - "email": "sam.doe@example.com", - "name": "Sam Doe" - } - ], - "cc": [ - { - "email": "jane.doe@example.com", - "name": "Jane Doe" - } - ], - "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", - "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, - "headers": { - "X-Accept-Language": "en", - "X-Mailer": "MyApp" - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "substitutions": { - "id": "substitutions", - "type": "object" - }, - "to": [ - { - "email": "john.doe@example.com", - "name": "John Doe" - } - ] - } - ], - "reply_to": { - "email": "sam.smith@example.com", - "name": "Sam Smith" - }, - "sections": { - "section": { - ":sectionName1": "section 1 text", - ":sectionName2": "section 2 text" - } - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "template_id": "[YOUR TEMPLATE ID GOES HERE]", - "tracking_settings": { - "click_tracking": { - "enable": true, - "enable_text": true - }, - "ganalytics": { - "enable": true, - "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", - "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", - "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", - "utm_name": "[NAME OF YOUR CAMPAIGN]", - "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" - }, - "open_tracking": { - "enable": true, - "substitution_tag": "%opentrack" - }, - "subscription_tracking": { - "enable": true, - "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", - "substitution_tag": "<%click here%>", - "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>." - } - } -}'); -$response = $sg->client->mail()->send()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mail_settings"></a> -# MAIL SETTINGS - -## Retrieve all mail settings - -**This endpoint allows you to retrieve a list of all mail settings.** - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->mail_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update address whitelist mail settings - -**This endpoint allows you to update your current email address whitelist settings.** - -The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/address_whitelist - - -```php -$request_body = json_decode('{ - "enabled": true, - "list": [ - "email1@example.com", - "example.com" - ] -}'); -$response = $sg->client->mail_settings()->address_whitelist()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve address whitelist mail settings - -**This endpoint allows you to retrieve your current email address whitelist settings.** - -The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/address_whitelist - - -```php -$response = $sg->client->mail_settings()->address_whitelist()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update BCC mail settings - -**This endpoint allows you to update your current BCC mail settings.** - -When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/bcc - - -```php -$request_body = json_decode('{ - "email": "email@example.com", - "enabled": false -}'); -$response = $sg->client->mail_settings()->bcc()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all BCC mail settings - -**This endpoint allows you to retrieve your current BCC mail settings.** - -When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/bcc - - -```php -$response = $sg->client->mail_settings()->bcc()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update bounce purge mail settings - -**This endpoint allows you to update your current bounce purge settings.** - -This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/bounce_purge - - -```php -$request_body = json_decode('{ - "enabled": true, - "hard_bounces": 5, - "soft_bounces": 5 -}'); -$response = $sg->client->mail_settings()->bounce_purge()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve bounce purge mail settings - -**This endpoint allows you to retrieve your current bounce purge settings.** - -This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/bounce_purge - - -```php -$response = $sg->client->mail_settings()->bounce_purge()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update footer mail settings - -**This endpoint allows you to update your current Footer mail settings.** - -The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/footer - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "...", - "plain_content": "..." -}'); -$response = $sg->client->mail_settings()->footer()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve footer mail settings - -**This endpoint allows you to retrieve your current Footer mail settings.** - -The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/footer - - -```php -$response = $sg->client->mail_settings()->footer()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update forward bounce mail settings - -**This endpoint allows you to update your current bounce forwarding mail settings.** - -Activating this setting allows you to specify an email address to which bounce reports are forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/forward_bounce - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "enabled": true -}'); -$response = $sg->client->mail_settings()->forward_bounce()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve forward bounce mail settings - -**This endpoint allows you to retrieve your current bounce forwarding mail settings.** - -Activating this setting allows you to specify an email address to which bounce reports are forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/forward_bounce - - -```php -$response = $sg->client->mail_settings()->forward_bounce()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update forward spam mail settings - -**This endpoint allows you to update your current Forward Spam mail settings.** - -Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/forward_spam - - -```php -$request_body = json_decode('{ - "email": "", - "enabled": false -}'); -$response = $sg->client->mail_settings()->forward_spam()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve forward spam mail settings - -**This endpoint allows you to retrieve your current Forward Spam mail settings.** - -Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/forward_spam - - -```php -$response = $sg->client->mail_settings()->forward_spam()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update plain content mail settings - -**This endpoint allows you to update your current Plain Content mail settings.** - -The plain content setting will automatically convert any plain text emails that you send to HTML before sending. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/plain_content - - -```php -$request_body = json_decode('{ - "enabled": false -}'); -$response = $sg->client->mail_settings()->plain_content()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve plain content mail settings - -**This endpoint allows you to retrieve your current Plain Content mail settings.** - -The plain content setting will automatically convert any plain text emails that you send to HTML before sending. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/plain_content - - -```php -$response = $sg->client->mail_settings()->plain_content()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update spam check mail settings - -**This endpoint allows you to update your current spam checker mail settings.** - -The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/spam_check - - -```php -$request_body = json_decode('{ - "enabled": true, - "max_score": 5, - "url": "url" -}'); -$response = $sg->client->mail_settings()->spam_check()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve spam check mail settings - -**This endpoint allows you to retrieve your current Spam Checker mail settings.** - -The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/spam_check - - -```php -$response = $sg->client->mail_settings()->spam_check()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update template mail settings - -**This endpoint allows you to update your current legacy email template settings.** - -This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/template - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "<% body %>" -}'); -$response = $sg->client->mail_settings()->template()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve legacy template mail settings - -**This endpoint allows you to retrieve your current legacy email template settings.** - -This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/template - - -```php -$response = $sg->client->mail_settings()->template()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mailbox_providers"></a> -# MAILBOX PROVIDERS - -## Retrieve email statistics by mailbox provider. - -**This endpoint allows you to retrieve your email statistics segmented by recipient mailbox provider.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /mailbox_providers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "mailbox_providers": "test_string", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); -$response = $sg->client->mailbox_providers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="partner_settings"></a> -# PARTNER SETTINGS - -## Returns a list of all partner settings. - -**This endpoint allows you to retrieve a list of all partner settings that you can enable.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -### GET /partner_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->partner_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Updates New Relic partner settings. - -**This endpoint allows you to update or change your New Relic partner settings.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html). - -### PATCH /partner_settings/new_relic - - -```php -$request_body = json_decode('{ - "enable_subuser_statistics": true, - "enabled": true, - "license_key": "" -}'); -$response = $sg->client->partner_settings()->new_relic()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Returns all New Relic partner settings. - -**This endpoint allows you to retrieve your current New Relic partner settings.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html). - -### GET /partner_settings/new_relic - - -```php -$response = $sg->client->partner_settings()->new_relic()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="scopes"></a> -# SCOPES - -## Retrieve a list of scopes for which this user has access. - -**This endpoint returns a list of all scopes that this user has access to.** - -API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html). - -### GET /scopes - - -```php -$response = $sg->client->scopes()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="senders"></a> -# SENDERS - -## Create a Sender Identity - -**This endpoint allows you to create a new sender identity.** - -*You may create up to 100 unique sender identities.* - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### POST /senders - - -```php -$request_body = json_decode('{ - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" -}'); -$response = $sg->client->senders()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get all Sender Identities - -**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### GET /senders - - -```php -$response = $sg->client->senders()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Sender Identity - -**This endpoint allows you to update a sender identity.** - -Updates to `from.email` require re-verification. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request. - -### PATCH /senders/{sender_id} - - -```php -$request_body = json_decode('{ - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" -}'); -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## View a Sender Identity - -**This endpoint allows you to retrieve a specific sender identity.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### GET /senders/{sender_id} - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Sender Identity - -**This endoint allows you to delete one of your sender identities.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### DELETE /senders/{sender_id} - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Resend Sender Identity Verification - -**This enpdoint allows you to resend a sender identity verification email.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### POST /senders/{sender_id}/resend_verification - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->resend_verification()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="stats"></a> -# STATS - -## Retrieve global email statistics - -**This endpoint allows you to retrieve all of your global email statistics between a given date range.** - -Parent accounts will see aggregated stats for their account and all subuser accounts. Subuser accounts will only see their own stats. - -### GET /stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); -$response = $sg->client->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="subusers"></a> -# SUBUSERS - -## Create Subuser - -This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### POST /subusers - - -```php -$request_body = json_decode('{ - "email": "John@example.com", - "ips": [ - "1.1.1.1", - "2.2.2.2" - ], - "password": "johns_password", - "username": "John@example.com" -}'); -$response = $sg->client->subusers()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List all Subusers - -This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### GET /subusers - - -```php -$query_params = json_decode('{"username": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->subusers()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Subuser Reputations - -Subuser sender reputations give a good idea how well a sender is doing with regards to how recipients and recipient servers react to the mail that is being received. When a bounce, spam report, or other negative action happens on a sent email, it will effect your sender rating. - -This endpoint allows you to request the reputations for your subusers. - -### GET /subusers/reputations - - -```php -$query_params = json_decode('{"usernames": "test_string"}'); -$response = $sg->client->subusers()->reputations()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve email statistics for your subusers. - -**This endpoint allows you to retrieve the email statistics for the given subusers.** - -You may retrieve statistics for up to 10 different subusers by including an additional _subusers_ parameter for each additional subuser. - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}'); -$response = $sg->client->subusers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve monthly stats for all subusers - -**This endpoint allows you to retrieve the monthly email statistics for all subusers over the given date range.** - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics: -`bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats/monthly - - -```php -$query_params = json_decode('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}'); -$response = $sg->client->subusers()->stats()->monthly()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the totals for each email statistic metric for all subusers. - -**This endpoint allows you to retrieve the total sums of each email statistic metric for all subusers over the given date range.** - - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats/sums - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); -$response = $sg->client->subusers()->stats()->sums()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Enable/disable a subuser - -This endpoint allows you to enable or disable a subuser. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### PATCH /subusers/{subuser_name} - - -```php -$request_body = json_decode('{ - "disabled": false -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a subuser - -This endpoint allows you to delete a subuser. This is a permanent action, once deleted a subuser cannot be retrieved. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### DELETE /subusers/{subuser_name} - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update IPs assigned to a subuser - -Each subuser should be assigned to an IP address, from which all of this subuser's mail will be sent. Often, this is the same IP as the parent account, but each subuser can have their own, or multiple, IP addresses as well. - -More information: - -* [How to request more IPs](https://sendgrid.com/docs/Classroom/Basics/Account/adding_an_additional_dedicated_ip_to_your_account.html) -* [IPs can be whitelabeled](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/ips.html) - -### PUT /subusers/{subuser_name}/ips - - -```php -$request_body = json_decode('[ - "127.0.0.1" -]'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->ips()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Monitor Settings for a subuser - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### PUT /subusers/{subuser_name}/monitor - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "frequency": 500 -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create monitor settings - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### POST /subusers/{subuser_name}/monitor - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "frequency": 50000 -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve monitor settings for a subuser - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### GET /subusers/{subuser_name}/monitor - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete monitor settings - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### DELETE /subusers/{subuser_name}/monitor - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the monthly email statistics for a single subuser - -**This endpoint allows you to retrive the monthly email statistics for a specific subuser.** - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics: -`bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/{subuser_name}/stats/monthly - - -```php -$query_params = json_decode('{"date": "test_string", "sort_by_direction": "asc", "limit": 1, "sort_by_metric": "test_string", "offset": 1}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->stats()->monthly()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="suppression"></a> -# SUPPRESSION - -## Retrieve all blocks - -**This endpoint allows you to retrieve a list of all email addresses that are currently on your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### GET /suppression/blocks - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->blocks()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete blocks - -**This endpoint allows you to delete all email addresses on your blocks list.** - -There are two options for deleting blocked emails: - -1. You can delete all blocked emails by setting `delete_all` to true in the request body. -2. You can delete some blocked emails by specifying the email addresses in an array in the request body. - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### DELETE /suppression/blocks - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->blocks()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific block - -**This endpoint allows you to retrieve a specific email address from your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### GET /suppression/blocks/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->blocks()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific block - -**This endpoint allows you to delete a specific email address from your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### DELETE /suppression/blocks/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->blocks()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all bounces - -**This endpoint allows you to retrieve all of your bounces.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) - -### GET /suppression/bounces - - -```php -$query_params = json_decode('{"start_time": 1, "end_time": 1}'); -$response = $sg->client->suppression()->bounces()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete bounces - -**This endpoint allows you to delete all of your bounces. You can also use this endpoint to remove a specific email address from your bounce list.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -Note: the `delete_all` and `emails` parameters should be used independently of each other as they have different purposes. - -### DELETE /suppression/bounces - - -```php -$request_body = json_decode('{ - "delete_all": true, - "emails": [ - "example@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->bounces()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Bounce - -**This endpoint allows you to retrieve a specific bounce for a given email address.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -### GET /suppression/bounces/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->bounces()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a bounce - -**This endpoint allows you to remove an email address from your bounce list.** - -Bounces are messages that are returned to the server that sent it. This endpoint allows you to delete a single email addresses from your bounce list. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -### DELETE /suppression/bounces/{email} - - -```php -$query_params = json_decode('{"email_address": "example@example.com"}'); -$email = "test_url_param"; -$response = $sg->client->suppression()->bounces()->_($email)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all invalid emails - -**This endpoint allows you to retrieve a list of all invalid email addresses.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### GET /suppression/invalid_emails - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->invalid_emails()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete invalid emails - -**This endpoint allows you to remove email addresses from your invalid email address list.** - -There are two options for deleting invalid email addresses: - -1) You can delete all invalid email addresses by setting `delete_all` to true in the request body. -2) You can delete some invalid email addresses by specifying certain addresses in an array in the request body. - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### DELETE /suppression/invalid_emails - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->invalid_emails()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific invalid email - -**This endpoint allows you to retrieve a specific invalid email addresses.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### GET /suppression/invalid_emails/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->invalid_emails()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific invalid email - -**This endpoint allows you to remove a specific email address from the invalid email address list.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### DELETE /suppression/invalid_emails/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->invalid_emails()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific spam report - -**This endpoint allows you to retrieve a specific spam report.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### GET /suppression/spam_report/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->spam_report()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific spam report - -**This endpoint allows you to delete a specific spam report.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### DELETE /suppression/spam_report/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->spam_report()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all spam reports - -**This endpoint allows you to retrieve all spam reports.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### GET /suppression/spam_reports - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->spam_reports()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete spam reports - -**This endpoint allows you to delete your spam reports.** - -There are two options for deleting spam reports: - -1) You can delete all spam reports by setting "delete_all" to true in the request body. -2) You can delete some spam reports by specifying the email addresses in an array in the request body. - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### DELETE /suppression/spam_reports - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->spam_reports()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all global suppressions - -**This endpoint allows you to retrieve a list of all email address that are globally suppressed.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### GET /suppression/unsubscribes - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->unsubscribes()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="templates"></a> -# TEMPLATES - -## Create a transactional template. - -**This endpoint allows you to create a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -### POST /templates - - -```php -$request_body = json_decode('{ - "name": "example_name" -}'); -$response = $sg->client->templates()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all transactional templates. - -**This endpoint allows you to retrieve all transactional templates.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -### GET /templates - - -```php -$response = $sg->client->templates()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Edit a transactional template. - -**This endpoint allows you to edit a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### PATCH /templates/{template_id} - - -```php -$request_body = json_decode('{ - "name": "new_example_name" -}'); -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single transactional template. - -**This endpoint allows you to retrieve a single transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### GET /templates/{template_id} - - -```php -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a template. - -**This endpoint allows you to delete a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### DELETE /templates/{template_id} - - -```php -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a new transactional template version. - -**This endpoint allows you to create a new version of a template.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### POST /templates/{template_id}/versions - - -```php -$request_body = json_decode('{ - "active": 1, - "html_content": "<%body%>", - "name": "example_version_name", - "plain_content": "<%body%>", - "subject": "<%subject%>", - "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" -}'); -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Edit a transactional template version. - -**This endpoint allows you to edit a version of one of your transactional templates.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### PATCH /templates/{template_id}/versions/{version_id} - - -```php -$request_body = json_decode('{ - "active": 1, - "html_content": "<%body%>", - "name": "updated_example_name", - "plain_content": "<%body%>", - "subject": "<%subject%>" -}'); -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific transactional template version. - -**This endpoint allows you to retrieve a specific version of a template.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### GET /templates/{template_id}/versions/{version_id} - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a transactional template version. - -**This endpoint allows you to delete one of your transactional template versions.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### DELETE /templates/{template_id}/versions/{version_id} - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Activate a transactional template version. - -**This endpoint allows you to activate a version of one of your templates.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### POST /templates/{template_id}/versions/{version_id}/activate - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->activate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="tracking_settings"></a> -# TRACKING SETTINGS - -## Retrieve Tracking Settings - -**This endpoint allows you to retrieve a list of all tracking settings that you can enable on your account.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->tracking_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Click Tracking Settings - -**This endpoint allows you to change your current click tracking setting. You can enable, or disable, click tracking using this endpoint.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/click - - -```php -$request_body = json_decode('{ - "enabled": true -}'); -$response = $sg->client->tracking_settings()->click()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Click Track Settings - -**This endpoint allows you to retrieve your current click tracking setting.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/click - - -```php -$response = $sg->client->tracking_settings()->click()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Google Analytics Settings - -**This endpoint allows you to update your current setting for Google Analytics.** - -For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445). - -We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html). - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/google_analytics - - -```php -$request_body = json_decode('{ - "enabled": true, - "utm_campaign": "website", - "utm_content": "", - "utm_medium": "email", - "utm_source": "sendgrid.com", - "utm_term": "" -}'); -$response = $sg->client->tracking_settings()->google_analytics()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Google Analytics Settings - -**This endpoint allows you to retrieve your current setting for Google Analytics.** - -For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445). - -We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html). - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/google_analytics - - -```php -$response = $sg->client->tracking_settings()->google_analytics()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Open Tracking Settings - -**This endpoint allows you to update your current settings for open tracking.** - -Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/open - - -```php -$request_body = json_decode('{ - "enabled": true -}'); -$response = $sg->client->tracking_settings()->open()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get Open Tracking Settings - -**This endpoint allows you to retrieve your current settings for open tracking.** - -Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/open - - -```php -$response = $sg->client->tracking_settings()->open()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Subscription Tracking Settings - -**This endpoint allows you to update your current settings for subscription tracking.** - -Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/subscription - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "html content", - "landing": "landing page html", - "plain_content": "text content", - "replace": "replacement tag", - "url": "url" -}'); -$response = $sg->client->tracking_settings()->subscription()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Subscription Tracking Settings - -**This endpoint allows you to retrieve your current settings for subscription tracking.** - -Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/subscription - - -```php -$response = $sg->client->tracking_settings()->subscription()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="user"></a> -# USER - -## Get a user's account information. - -**This endpoint allows you to retrieve your user account details.** - -Your user's account information includes the user's account type and reputation. - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/account - - -```php -$response = $sg->client->user()->account()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your credit balance - -**This endpoint allows you to retrieve the current credit balance for your account.** - -Your monthly credit allotment limits the number of emails you may send before incurring overage charges. For more information about credits and billing, please visit our [Clssroom](https://sendgrid.com/docs/Classroom/Basics/Billing/billing_info_and_faqs.html). - -### GET /user/credits - - -```php -$response = $sg->client->user()->credits()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your account email address - -**This endpoint allows you to update the email address currently on file for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/email - - -```php -$request_body = json_decode('{ - "email": "example@example.com" -}'); -$response = $sg->client->user()->email()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your account email address - -**This endpoint allows you to retrieve the email address currently on file for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/email - - -```php -$response = $sg->client->user()->email()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your password - -**This endpoint allows you to update your password.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/password - - -```php -$request_body = json_decode('{ - "new_password": "new_password", - "old_password": "old_password" -}'); -$response = $sg->client->user()->password()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a user's profile - -**This endpoint allows you to update your current profile details.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -It should be noted that any one or more of the parameters can be updated via the PATCH /user/profile endpoint. The only requirement is that you include at least one when you PATCH. - -### PATCH /user/profile - - -```php -$request_body = json_decode('{ - "city": "Orange", - "first_name": "Example", - "last_name": "User" -}'); -$response = $sg->client->user()->profile()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get a user's profile - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/profile - - -```php -$response = $sg->client->user()->profile()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Cancel or pause a scheduled send - -**This endpoint allows you to cancel or pause an email that has been scheduled to be sent.** - -If the maximum number of cancellations/pauses are added, HTTP 400 will -be returned. - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### POST /user/scheduled_sends - - -```php -$request_body = json_decode('{ - "batch_id": "YOUR_BATCH_ID", - "status": "pause" -}'); -$response = $sg->client->user()->scheduled_sends()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all scheduled sends - -**This endpoint allows you to retrieve all cancel/paused scheduled send information.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### GET /user/scheduled_sends - - -```php -$response = $sg->client->user()->scheduled_sends()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update user scheduled send information - -**This endpoint allows you to update the status of a scheduled send for the given `batch_id`.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### PATCH /user/scheduled_sends/{batch_id} - - -```php -$request_body = json_decode('{ - "status": "pause" -}'); -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve scheduled send - -**This endpoint allows you to retrieve the cancel/paused scheduled send information for a specific `batch_id`.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### GET /user/scheduled_sends/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a cancellation or pause of a scheduled send - -**This endpoint allows you to delete the cancellation/pause of a scheduled send.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### DELETE /user/scheduled_sends/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Enforced TLS settings - -**This endpoint allows you to update your current Enforced TLS settings.** - -The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS. - -**Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description. - -### PATCH /user/settings/enforced_tls - - -```php -$request_body = json_decode('{ - "require_tls": true, - "require_valid_cert": false -}'); -$response = $sg->client->user()->settings()->enforced_tls()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve current Enforced TLS settings. - -**This endpoint allows you to retrieve your current Enforced TLS settings.** - -The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS. - -**Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description. - -### GET /user/settings/enforced_tls - - -```php -$response = $sg->client->user()->settings()->enforced_tls()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your username - -**This endpoint allows you to update the username for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/username - - -```php -$request_body = json_decode('{ - "username": "test_username" -}'); -$response = $sg->client->user()->username()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your username - -**This endpoint allows you to retrieve your current account username.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/username - - -```php -$response = $sg->client->user()->username()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Event Notification Settings - -**This endpoint allows you to update your current event webhook settings.** - -If an event type is marked as `true`, then the event webhook will include information about that event. - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### PATCH /user/webhooks/event/settings - - -```php -$request_body = json_decode('{ - "bounce": true, - "click": true, - "deferred": true, - "delivered": true, - "dropped": true, - "enabled": true, - "group_resubscribe": true, - "group_unsubscribe": true, - "open": true, - "processed": true, - "spam_report": true, - "unsubscribe": true, - "url": "url" -}'); -$response = $sg->client->user()->webhooks()->event()->settings()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Event Webhook settings - -**This endpoint allows you to retrieve your current event webhook settings.** - -If an event type is marked as `true`, then the event webhook will include information about that event. - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### GET /user/webhooks/event/settings - - -```php -$response = $sg->client->user()->webhooks()->event()->settings()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Test Event Notification Settings - -**This endpoint allows you to test your event webhook by sending a fake event notification post to the provided URL.** - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### POST /user/webhooks/event/test - - -```php -$request_body = json_decode('{ - "url": "url" -}'); -$response = $sg->client->user()->webhooks()->event()->test()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a parse setting - -**This endpoint allows you to create a new inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### POST /user/webhooks/parse/settings - - -```php -$request_body = json_decode('{ - "hostname": "myhostname.com", - "send_raw": false, - "spam_check": true, - "url": "http://email.myhosthame.com" -}'); -$response = $sg->client->user()->webhooks()->parse()->settings()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all parse settings - -**This endpoint allows you to retrieve all of your current inbound parse settings.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### GET /user/webhooks/parse/settings - - -```php -$response = $sg->client->user()->webhooks()->parse()->settings()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a parse setting - -**This endpoint allows you to update a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### PATCH /user/webhooks/parse/settings/{hostname} - - -```php -$request_body = json_decode('{ - "send_raw": true, - "spam_check": false, - "url": "http://newdomain.com/parse" -}'); -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific parse setting - -**This endpoint allows you to retrieve a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### GET /user/webhooks/parse/settings/{hostname} - - -```php -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a parse setting - -**This endpoint allows you to delete a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### DELETE /user/webhooks/parse/settings/{hostname} - - -```php -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieves Inbound Parse Webhook statistics. - -**This endpoint allows you to retrieve the statistics for your Parse Webhook useage.** - -SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incomming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 20MB in size, including all attachments. - -There are a number of pre-made integrations for the SendGrid Parse Webhook which make processing events easy. You can find these integrations in the [Library Index](https://sendgrid.com/docs/Integrate/libraries.html#-Webhook-Libraries). - -### GET /user/webhooks/parse/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": "test_string", "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": "test_string"}'); -$response = $sg->client->user()->webhooks()->parse()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="whitelabel"></a> -# WHITELABEL - -## Create a domain whitelabel. - -**This endpoint allows you to create a whitelabel for one of your domains.** - -If you are creating a domain whitelabel that you would like a subuser to use, you have two options: -1. Use the "username" parameter. This allows you to create a whitelabel on behalf of your subuser. This means the subuser is able to see and modify the created whitelabel. -2. Use the Association workflow (see Associate Domain section). This allows you to assign a whitelabel created by the parent to a subuser. This means the subuser will default to the assigned whitelabel, but will not be able to see or modify that whitelabel. However, if the subuser creates their own whitelabel it will overwrite the assigned whitelabel. - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### POST /whitelabel/domains - - -```php -$request_body = json_decode('{ - "automatic_security": false, - "custom_spf": true, - "default": true, - "domain": "example.com", - "ips": [ - "192.168.1.1", - "192.168.1.2" - ], - "subdomain": "news", - "username": "john@example.com" -}'); -$response = $sg->client->whitelabel()->domains()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List all domain whitelabels. - -**This endpoint allows you to retrieve a list of all domain whitelabels you have created.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - - -### GET /whitelabel/domains - - -```php -$query_params = json_decode('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->domains()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get the default domain whitelabel. - -**This endpoint allows you to retrieve the default whitelabel for a domain.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| domain | string |The domain to find a default domain whitelabel for. | - -### GET /whitelabel/domains/default - - -```php -$response = $sg->client->whitelabel()->domains()->default()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List the domain whitelabel associated with the given user. - -**This endpoint allows you to retrieve all of the whitelabels that have been assigned to a specific subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| username | string | Username of the subuser to find associated whitelabels for. | - -### GET /whitelabel/domains/subuser - - -```php -$response = $sg->client->whitelabel()->domains()->subuser()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Disassociate a domain whitelabel from a given user. - -**This endpoint allows you to disassociate a specific whitelabel from a subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -| username | string | required | Username for the subuser to find associated whitelabels for. | - -### DELETE /whitelabel/domains/subuser - - -```php -$response = $sg->client->whitelabel()->domains()->subuser()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a domain whitelabel. - -**This endpoint allows you to update the settings for a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### PATCH /whitelabel/domains/{domain_id} - - -```php -$request_body = json_decode('{ - "custom_spf": true, - "default": false -}'); -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a domain whitelabel. - -**This endpoint allows you to retrieve a specific domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - - -### GET /whitelabel/domains/{domain_id} - - -```php -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a domain whitelabel. - -**This endpoint allows you to delete a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### DELETE /whitelabel/domains/{domain_id} - - -```php -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Associate a domain whitelabel with a given user. - -**This endpoint allows you to associate a specific domain whitelabel with a subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| domain_id | integer | ID of the domain whitelabel to associate with the subuser. | - -### POST /whitelabel/domains/{domain_id}/subuser - - -```php -$request_body = json_decode('{ - "username": "jane@example.com" -}'); -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->subuser()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP to a domain whitelabel. - -**This endpoint allows you to add an IP address to a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer | ID of the domain to which you are adding an IP | - -### POST /whitelabel/domains/{id}/ips - - -```php -$request_body = json_decode('{ - "ip": "192.168.0.1" -}'); -$id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP from a domain whitelabel. - -**This endpoint allows you to remove a domain's IP address from that domain's whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer | ID of the domain whitelabel to delete the IP from. | -| ip | string | IP to remove from the domain whitelabel. | - -### DELETE /whitelabel/domains/{id}/ips/{ip} - - -```php -$id = "test_url_param"; -$ip = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->ips()->_($ip)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate a domain whitelabel. - -**This endpoint allows you to validate a domain whitelabel. If it fails, it will return an error message describing why the whitelabel could not be validated.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer |ID of the domain whitelabel to validate. | - -### POST /whitelabel/domains/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create an IP whitelabel - -**This endpoint allows you to create an IP whitelabel.** - -When creating an IP whitelable, you should use the same subdomain that you used when you created a domain whitelabel. - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### POST /whitelabel/ips - - -```php -$request_body = json_decode('{ - "domain": "example.com", - "ip": "192.168.1.1", - "subdomain": "email" -}'); -$response = $sg->client->whitelabel()->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP whitelabels - -**This endpoint allows you to retrieve all of the IP whitelabels that have been createdy by this account.** - -You may include a search key by using the "ip" parameter. This enables you to perform a prefix search for a given IP segment (e.g. "192."). - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### GET /whitelabel/ips - - -```php -$query_params = json_decode('{"ip": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->ips()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve an IP whitelabel - -**This endpoint allows you to retrieve an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### GET /whitelabel/ips/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an IP whitelabel - -**This endpoint allows you to delete an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### DELETE /whitelabel/ips/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate an IP whitelabel - -**This endpoint allows you to validate an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### POST /whitelabel/ips/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a Link Whitelabel - -**This endpoint allows you to create a new link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links - - -```php -$request_body = json_decode('{ - "default": true, - "domain": "example.com", - "subdomain": "mail" -}'); -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->links()->post($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all link whitelabels - -**This endpoint allows you to retrieve all link whitelabels.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->whitelabel()->links()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Default Link Whitelabel - -**This endpoint allows you to retrieve the default link whitelabel.** - -Default link whitelabel is the actual link whitelabel to be used when sending messages. If there are multiple link whitelabels, the default is determined by the following order: -<ul> - <li>Validated link whitelabels marked as "default"</li> - <li>Legacy link whitelabels (migrated from the whitelabel wizard)</li> - <li>Default SendGrid link whitelabel (i.e. 100.ct.sendgrid.net)</li> -</ul> - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/default - - -```php -$query_params = json_decode('{"domain": "test_string"}'); -$response = $sg->client->whitelabel()->links()->default()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Associated Link Whitelabel - -**This endpoint allows you to retrieve the associated link whitelabel for a subuser.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/subuser - - -```php -$query_params = json_decode('{"username": "test_string"}'); -$response = $sg->client->whitelabel()->links()->subuser()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Disassociate a Link Whitelabel - -**This endpoint allows you to disassociate a link whitelabel from a subuser.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### DELETE /whitelabel/links/subuser - - -```php -$query_params = json_decode('{"username": "test_string"}'); -$response = $sg->client->whitelabel()->links()->subuser()->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Link Whitelabel - -**This endpoint allows you to update a specific link whitelabel. You can use this endpoint to change a link whitelabel's default status.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### PATCH /whitelabel/links/{id} - - -```php -$request_body = json_decode('{ - "default": true -}'); -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Link Whitelabel - -**This endpoint allows you to retrieve a specific link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Link Whitelabel - -**This endpoint allows you to delete a link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### DELETE /whitelabel/links/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate a Link Whitelabel - -**This endpoint allows you to validate a link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Associate a Link Whitelabel - -**This endpoint allows you to associate a link whitelabel with a subuser account.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links/{link_id}/subuser - - -```php -$request_body = json_decode('{ - "username": "jane@example.com" -}'); -$link_id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($link_id)->subuser()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` - diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md deleted file mode 100644 index c7cb0a1..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md +++ /dev/null @@ -1,168 +0,0 @@ -This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-php/issues) or make a pull request for any use cases you would like us to document here. Thank you! - -# Table of Contents -* [Attachments](#attachments) -* [Transactional Templates](#transactional_templates) - -<a name="attachments"></a> -# Attachments - -Here is an example of attaching a text file to your email, assuming that text file `my_file.txt` is located in the same directory. - -```php -<?php -// using SendGrid's PHP Library -// https://github.com/sendgrid/sendgrid-php - -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$from = new SendGrid\Email("Example User", "test@example.com"); -$subject = "Sending with SendGrid is Fun"; -$to = new SendGrid\Email("Example User", "test@example.com"); -$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP"); -$file = 'my_file.txt'; -$file_encoded = base64_encode(file_get_contents($file)); -$attachment = new SendGrid\Attachment(); -$attachment->setContent($file_encoded); -$attachment->setType("application/text"); -$attachment->setDisposition("attachment"); -$attachment->setFilename("my_file.txt"); - -$mail = new SendGrid\Mail($from, $subject, $to, $content); -$mail->addAttachment($attachment); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -$response = $sg->client->mail()->send()->post($mail); -echo $response->statusCode(); -print_r($response->headers()); -echo $response->body(); - -?> -``` - -<a name="transactional_templates"></a> -# Transactional Templates - -For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing. - -Template ID (replace with your own): - -```text -13b8f94f-bcae-4ec6-b752-70d6cb59f932 -``` - -Email Subject: - -```text -<%subject%> -``` - -Template Body: - -```html -<html> -<head> - <title></title> -</head> -<body> -Hello -name-, -<br /><br/> -I'm glad you are trying out the template feature! -<br /><br/> -<%body%> -<br /><br/> -I hope you are having a great day in -city- :) -<br /><br/> -</body> -</html> -``` - -## With Mail Helper Class - -```php -<?php -// If you are using Composer -require 'vendor/autoload.php'; - -// If you are not using Composer (recommended) -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$from = new SendGrid\Email(null, "test@example.com"); -$subject = "I'm replacing the subject tag"; -$to = new SendGrid\Email(null, "test@example.com"); -$content = new SendGrid\Content("text/html", "I'm replacing the <strong>body tag</strong>"); -$mail = new SendGrid\Mail($from, $subject, $to, $content); -$mail->personalization[0]->addSubstitution("-name-", "Example User"); -$mail->personalization[0]->addSubstitution("-city-", "Denver"); -$mail->setTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932"); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -try { - $response = $sg->client->mail()->send()->post($mail); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} - -echo $response->statusCode(); -print_r($response->headers()); -echo $response->body(); -``` - -## Without Mail Helper Class - -```php -<?php -// If you are using Composer -require 'vendor/autoload.php'; - -// If you are not using Composer (recommended) -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$request_body = json_decode('{ - "personalizations": [ - { - "to": [ - { - "email": "dx@sendgrid.com" - } - ], - "substitutions": { - "-name-": "Example User", - "-city-": "Denver" - }, - "subject": "I\'m replacing the subject tag" - } - ], - "from": { - "email": "elmer@sendgrid.com" - }, - "content": [ - { - "type": "text/html", - "value": "I\'m replacing the <strong>body tag</strong>" - } - ], - "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932" -}'); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -try { - $response = $sg->client->mail()->send()->post($request_body); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} - -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/composer.json b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/composer.json index 2e2a398..d7dea0e 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/composer.json +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/composer.json @@ -1,23 +1,47 @@ { "name": "sendgrid/sendgrid", - "description": "This library allows you to quickly and easily send emails through SendGrid using PHP.", - "version": "6.0.0", + "description": "This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.", + "version": "7.3.0", "homepage": "http://github.com/sendgrid/sendgrid-php", "license": "MIT", - "keywords": ["SendGrid", "sendgrid", "email", "send", "grid"], + "keywords": [ + "SendGrid", + "sendgrid", + "Twilio SendGrid", + "twilio sendgrid", + "email", + "send", + "grid" + ], "require": { "php": ">=5.6", - "sendgrid/php-http-client": "~3.7" + "sendgrid/php-http-client": "~3.9", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*" }, "require-dev": { - "phpunit/phpunit": "4.*", - "squizlabs/php_codesniffer": "2.*" + "phpunit/phpunit": "^5.7.9 || ^6.4.3", + "squizlabs/php_codesniffer": "3.*", + "swaggest/json-diff": "^3.4" }, "replace": { "sendgrid/sendgrid-php": "*" }, "type": "library", "autoload": { - "files": ["lib/SendGrid.php", "lib/helpers/mail/Mail.php"] + "psr-4": { + "SendGrid\\": "lib/", + "SendGrid\\Mail\\": "lib/mail/", + "SendGrid\\Contacts\\": "lib/contacts/", + "SendGrid\\Stats\\": "lib/stats/" + }, + "files": ["lib/SendGrid.php"] + }, + "autoload-dev": { + "psr-4": { + "SendGrid\\Tests\\": "test/" + } } -}
\ No newline at end of file +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/SendGrid.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/SendGrid.php index 0bda1b5..08ee1d6 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/SendGrid.php +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/SendGrid.php @@ -1,43 +1,42 @@ <?php /** - * This library allows you to quickly and easily send emails through SendGrid using PHP. - * - * @author Elmer Thomas <dx@sendgrid.com> - * @copyright 2017 SendGrid - * @license https://opensource.org/licenses/MIT The MIT License - * @version GIT: <git_id> - * @link http://packagist.org/packages/sendgrid/sendgrid - */ + * This library allows you to quickly and easily send emails through + * Twilio SendGrid using PHP. + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ /** - * Interface to the SendGrid Web API - */ + * This class is the interface to the Twilio SendGrid Web API + * + * @package SendGrid\Mail + */ class SendGrid { - const VERSION = '6.0.0'; + const VERSION = '7.3.0'; - /** - * - * @var string - */ + // @var string protected $namespace = 'SendGrid'; - /** - * @var \SendGrid\Client - */ + // @var \SendGrid\Client public $client; - - /** - * @var string - */ + // @var string public $version = self::VERSION; /** - * Setup the HTTP Client - * - * @param string $apiKey your SendGrid API Key. - * @param array $options an array of options, currently only "host" and "curl" are implemented. - */ + * Setup the HTTP Client + * + * @param string $apiKey Your Twilio SendGrid API Key. + * @param array $options An array of options, currently only "host", "curl" and + * "impersonateSubuser" are implemented. + */ public function __construct($apiKey, $options = array()) { $headers = array( @@ -46,10 +45,33 @@ class SendGrid 'Accept: application/json' ); - $host = isset($options['host']) ? $options['host'] : 'https://api.sendgrid.com'; + $host = isset($options['host']) ? $options['host'] : + 'https://api.sendgrid.com'; + + if (!empty($options['impersonateSubuser'])) { + $headers[] = 'On-Behalf-Of: '. $options['impersonateSubuser']; + } $curlOptions = isset($options['curl']) ? $options['curl'] : null; - $this->client = new \SendGrid\Client($host, $headers, '/v3', null, $curlOptions); + $this->client = new \SendGrid\Client( + $host, + $headers, + '/v3', + null, + $curlOptions + ); + } + + /** + * Make an API request + * + * @param \SendGrid\Mail\Mail $email A Mail object, containing the request object + * + * @return \SendGrid\Response + */ + public function send(\SendGrid\Mail\Mail $email) + { + return $this->client->mail()->send()->post($email); } } diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php deleted file mode 100644 index ef4d8db..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php +++ /dev/null @@ -1,1172 +0,0 @@ -<?php -/** - * This helper builds the request body for a /mail/send API call. - * - * PHP version 5.6, 7 - * - * @author Elmer Thomas <dx@sendgrid.com> - * @copyright 2017 SendGrid - * @license https://opensource.org/licenses/MIT The MIT License - * @version GIT: <git_id> - * @link http://packagist.org/packages/sendgrid/sendgrid - */ -namespace SendGrid; - -class ReplyTo implements \JsonSerializable -{ - private $email; - private $name; - - public function __construct($email, $name = null) - { - $this->email = $email; - - if (!is_null($name)) { - $this->name = $name; - } - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'email' => $this->getEmail(), - 'name' => $this->getName(), - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class ClickTracking implements \JsonSerializable -{ - private $enable; - private $enable_text; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setEnableText($enable_text) - { - $this->enable_text = $enable_text; - } - - public function getEnableText() - { - return $this->enable_text; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'enable_text' => $this->getEnableText() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class OpenTracking implements \JsonSerializable -{ - private $enable; - private $substitution_tag; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setSubstitutionTag($substitution_tag) - { - $this->substitution_tag = $substitution_tag; - } - - public function getSubstitutionTag() - { - return $this->substitution_tag; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'substitution_tag' => $this->getSubstitutionTag() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SubscriptionTracking implements \JsonSerializable -{ - private $enable; - private $text; - private $html; - private $substitution_tag; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setText($text) - { - $this->text = $text; - } - - public function getText() - { - return $this->text; - } - - public function setHtml($html) - { - $this->html = $html; - } - - public function getHtml() - { - return $this->html; - } - - public function setSubstitutionTag($substitution_tag) - { - $this->substitution_tag = $substitution_tag; - } - - public function getSubstitutionTag() - { - return $this->substitution_tag; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'text' => $this->getText(), - 'html' => $this->getHtml(), - 'substitution_tag' => $this->getSubstitutionTag() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Ganalytics implements \JsonSerializable -{ - private $enable; - private $utm_source; - private $utm_medium; - private $utm_term; - private $utm_content; - private $utm_campaign; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setCampaignSource($utm_source) - { - $this->utm_source = $utm_source; - } - - public function getCampaignSource() - { - return $this->utm_source; - } - - public function setCampaignMedium($utm_medium) - { - $this->utm_medium = $utm_medium; - } - - public function getCampaignMedium() - { - return $this->utm_medium; - } - - public function setCampaignTerm($utm_term) - { - $this->utm_term = $utm_term; - } - - public function getCampaignTerm() - { - return $this->utm_term; - } - - public function setCampaignContent($utm_content) - { - $this->utm_content = $utm_content; - } - - public function getCampaignContent() - { - return $this->utm_content; - } - - public function setCampaignName($utm_campaign) - { - $this->utm_campaign = $utm_campaign; - } - - public function getCampaignName() - { - return $this->utm_campaign; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'utm_source' => $this->getCampaignSource(), - 'utm_medium' => $this->getCampaignMedium(), - 'utm_term' => $this->getCampaignTerm(), - 'utm_content' => $this->getCampaignContent(), - 'utm_campaign' => $this->getCampaignName() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class TrackingSettings implements \JsonSerializable -{ - private $click_tracking; - private $open_tracking; - private $subscription_tracking; - private $ganalytics; - - public function setClickTracking($click_tracking) - { - $this->click_tracking = $click_tracking; - } - - public function getClickTracking() - { - return $this->click_tracking; - } - - public function setOpenTracking($open_tracking) - { - $this->open_tracking = $open_tracking; - } - - public function getOpenTracking() - { - return $this->open_tracking; - } - - public function setSubscriptionTracking($subscription_tracking) - { - $this->subscription_tracking = $subscription_tracking; - } - - public function getSubscriptionTracking() - { - return $this->subscription_tracking; - } - - public function setGanalytics($ganalytics) - { - $this->ganalytics = $ganalytics; - } - - public function getGanalytics() - { - return $this->ganalytics; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'click_tracking' => $this->getClickTracking(), - 'open_tracking' => $this->getOpenTracking(), - 'subscription_tracking' => $this->getSubscriptionTracking(), - 'ganalytics' => $this->getGanalytics() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class BccSettings implements \JsonSerializable -{ - private $enable; - private $email; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'email' => $this->getEmail() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class BypassListManagement implements \JsonSerializable -{ - private $enable; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Footer implements \JsonSerializable -{ - private $enable; - private $text; - private $html; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setText($text) - { - $this->text = $text; - } - - public function getText() - { - return $this->text; - } - - public function setHtml($html) - { - $this->html = $html; - } - - public function getHtml() - { - return $this->html; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'text' => $this->getText(), - 'html' => $this->getHtml() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SandBoxMode implements \JsonSerializable -{ - private $enable; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SpamCheck implements \JsonSerializable -{ - private $enable; - private $threshold; - private $post_to_url; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setThreshold($threshold) - { - $this->threshold = $threshold; - } - - public function getThreshold() - { - return $this->threshold; - } - - public function setPostToUrl($post_to_url) - { - $this->post_to_url = $post_to_url; - } - - public function getPostToUrl() - { - return $this->post_to_url; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'threshold' => $this->getThreshold(), - 'post_to_url' => $this->getPostToUrl() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class MailSettings implements \JsonSerializable -{ - private $bcc; - private $bypass_list_management; - private $footer; - private $sandbox_mode; - private $spam_check; - - public function setBccSettings($bcc) - { - $this->bcc = $bcc; - } - - public function getBccSettings() - { - return $this->bcc; - } - - public function setBypassListManagement($bypass_list_management) - { - $this->bypass_list_management = $bypass_list_management; - } - - public function getBypassListManagement() - { - return $this->bypass_list_management; - } - - public function setFooter($footer) - { - $this->footer = $footer; - } - - public function getFooter() - { - return $this->footer; - } - - public function setSandboxMode($sandbox_mode) - { - $this->sandbox_mode = $sandbox_mode; - } - - public function getSandboxMode() - { - return $this->sandbox_mode; - } - - public function setSpamCheck($spam_check) - { - $this->spam_check = $spam_check; - } - - public function getSpamCheck() - { - return $this->spam_check; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'bcc' => $this->getBccSettings(), - 'bypass_list_management' => $this->getBypassListManagement(), - 'footer' => $this->getFooter(), - 'sandbox_mode' => $this->getSandboxMode(), - 'spam_check' => $this->getSpamCheck() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class ASM implements \JsonSerializable -{ - private $group_id; - private $groups_to_display; - - public function setGroupId($group_id) - { - $this->group_id = $group_id; - } - - public function getGroupId() - { - return $this->group_id; - } - - public function setGroupsToDisplay($group_ids) - { - $this->groups_to_display = $group_ids; - } - - public function getGroupsToDisplay() - { - return $this->groups_to_display; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'group_id' => $this->getGroupId(), - 'groups_to_display' => $this->getGroupsToDisplay() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Attachment implements \JsonSerializable -{ - private $content; - private $type; - private $filename; - private $disposition; - private $content_id; - - public function setContent($content) - { - $this->content = $content; - } - - public function getContent() - { - return $this->content; - } - - public function setType($type) - { - $this->type = $type; - } - - public function getType() - { - return $this->type; - } - - public function setFilename($filename) - { - $this->filename = $filename; - } - - public function getFilename() - { - return $this->filename; - } - - public function setDisposition($disposition) - { - $this->disposition = $disposition; - } - - public function getDisposition() - { - return $this->disposition; - } - - public function setContentID($content_id) - { - $this->content_id = $content_id; - } - - public function getContentID() - { - return $this->content_id; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'content' => $this->getContent(), - 'type' => $this->getType(), - 'filename' => $this->getFilename(), - 'disposition' => $this->getDisposition(), - 'content_id' => $this->getContentID() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Content implements \JsonSerializable -{ - private $type; - private $value; - - public function __construct($type, $value) - { - $this->type = $type; - $this->value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); - } - - public function setType($type) - { - $this->type = $type; - } - - public function getType() - { - return $this->type; - } - - public function setValue($value) - { - $this->value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); - } - - public function getValue() - { - return $this->value; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'type' => $this->getType(), - 'value' => $this->getValue() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Personalization implements \JsonSerializable -{ - private $tos; - private $ccs; - private $bccs; - private $subject; - private $headers; - private $substitutions; - private $custom_args; - private $send_at; - - public function addTo($email) - { - $this->tos[] = $email; - } - - public function getTos() - { - return $this->tos; - } - - public function addCc($email) - { - $this->ccs[] = $email; - } - - public function getCcs() - { - return $this->ccs; - } - - public function addBcc($email) - { - $this->bccs[] = $email; - } - - public function getBccs() - { - return $this->bccs; - } - - public function setSubject($subject) - { - $this->subject = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); - } - - public function getSubject() - { - return $this->subject; - } - - public function addHeader($key, $value) - { - $this->headers[$key] = $value; - } - - public function getHeaders() - { - return $this->headers; - } - - public function addSubstitution($key, $value) - { - $this->substitutions[$key] = $value; - } - - public function getSubstitutions() - { - return $this->substitutions; - } - - public function addCustomArg($key, $value) - { - $this->custom_args[$key] = (string)$value; - } - - public function getCustomArgs() - { - return $this->custom_args; - } - - public function setSendAt($send_at) - { - $this->send_at = $send_at; - } - - public function getSendAt() - { - return $this->send_at; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'to' => $this->getTos(), - 'cc' => $this->getCcs(), - 'bcc' => $this->getBccs(), - 'subject' => $this->subject, - 'headers' => $this->getHeaders(), - 'substitutions' => $this->getSubstitutions(), - 'custom_args' => $this->getCustomArgs(), - 'send_at' => $this->getSendAt() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Email implements \JsonSerializable -{ - private $name; - private $email; - - public function __construct($name, $email) - { - $this->name = $name; - $this->email = $email; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'name' => $this->getName(), - 'email' => $this->getEmail() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -/** - * The final request body object - */ -class Mail implements \JsonSerializable -{ - const VERSION = '1.0.0'; - - protected $namespace = 'SendGrid'; - - public $from; - public $personalization; - public $subject; - public $contents; - public $attachments; - public $template_id; - public $sections; - public $headers; - public $categories; - public $custom_args; - public $send_at; - public $batch_id; - public $asm; - public $ip_pool_name; - public $mail_settings; - public $tracking_settings; - public $reply_to; - - public function __construct($from, $subject, $to, $content) - { - $this->setFrom($from); - $this->setSubject($subject); - $personalization = new Personalization(); - $personalization->addTo($to); - $this->addPersonalization($personalization); - $this->addContent($content); - } - - public function setFrom($email) - { - $this->from = $email; - } - - public function getFrom() - { - return $this->from; - } - - public function addPersonalization($personalization) - { - $this->personalization[] = $personalization; - } - - public function getPersonalizations() - { - return $this->personalization; - } - - public function setSubject($subject) - { - $this->subject = $subject; - } - - public function getSubject() - { - return $this->subject; - } - - public function addContent($content) - { - $this->contents[] = $content; - } - - public function getContents() - { - return $this->contents; - } - - public function addAttachment($attachment) - { - $this->attachments[] = $attachment; - } - - public function getAttachments() - { - return $this->attachments; - } - - public function setTemplateId($template_id) - { - $this->template_id = $template_id; - } - - public function getTemplateId() - { - return $this->template_id; - } - - public function addSection($key, $value) - { - $this->sections[$key] = $value; - } - - public function getSections() - { - return $this->sections; - } - - public function addHeader($key, $value) - { - $this->headers[$key] = $value; - } - - public function getHeaders() - { - return $this->headers; - } - - public function addCategory($category) - { - $this->categories[] = $category; - } - - public function getCategories() - { - return $this->categories; - } - - public function addCustomArg($key, $value) - { - $this->custom_args[$key] = (string)$value; - } - - public function getCustomArgs() - { - return $this->custom_args; - } - - public function setSendAt($send_at) - { - $this->send_at = $send_at; - } - - public function getSendAt() - { - return $this->send_at; - } - - public function setBatchId($batch_id) - { - $this->batch_id = $batch_id; - } - - public function getBatchId() - { - return $this->batch_id; - } - - public function setASM($asm) - { - $this->asm = $asm; - } - - public function getASM() - { - return $this->asm; - } - - public function setIpPoolName($ip_pool_name) - { - $this->ip_pool_name = $ip_pool_name; - } - - public function getIpPoolName() - { - return $this->ip_pool_name; - } - - public function setMailSettings($mail_settings) - { - $this->mail_settings = $mail_settings; - } - - public function getMailSettings() - { - return $this->mail_settings; - } - - public function setTrackingSettings($tracking_settings) - { - $this->tracking_settings = $tracking_settings; - } - - public function getTrackingSettings() - { - return $this->tracking_settings; - } - - public function setReplyTo($reply_to) - { - $this->reply_to = $reply_to; - } - - public function getReplyTo() - { - return $this->reply_to; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'from' => $this->getFrom(), - 'personalizations' => $this->getPersonalizations(), - 'subject' => $this->getSubject(), - 'content' => $this->getContents(), - 'attachments' => $this->getAttachments(), - 'template_id' => $this->getTemplateId(), - 'sections' => $this->getSections(), - 'headers' => $this->getHeaders(), - 'categories' => $this->getCategories(), - 'custom_args' => $this->getCustomArgs(), - 'send_at' => $this->getSendAt(), - 'batch_id' => $this->getBatchId(), - 'asm' => $this->getASM(), - 'ip_pool_name' => $this->getIpPoolName(), - 'mail_settings' => $this->getMailSettings(), - 'tracking_settings' => $this->getTrackingSettings(), - 'reply_to' => $this->getReplyTo() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/README.md deleted file mode 100644 index fec01c6..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/README.md +++ /dev/null @@ -1,14 +0,0 @@ -**This helper allows you to quickly and easily build a Mail object for sending email through SendGrid.** - -# Quick Start - -Run the [example](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/mail/example.php) (make sure you have set your environment variable to include your SENDGRID_API_KEY). - -```bash -php examples/helpers/mail/example.php -``` - -## Usage - -- See this complete working [example](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/mail/example.php). -- [Documentation](https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/overview.html) diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/loader.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/loader.php index ed17dfe..9e6a749 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/loader.php +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/loader.php @@ -1,6 +1,54 @@ <?php /** * Allows us to include one file instead of two when working without composer. + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid */ require_once __DIR__ . '/SendGrid.php'; -require_once __DIR__ . '/helpers/mail/Mail.php'; +require_once __DIR__ . '/contacts/Recipient.php'; +require_once __DIR__ . '/contacts/RecipientForm.php'; +require_once __DIR__ . '/mail/EmailAddress.php'; +require_once __DIR__ . '/mail/Asm.php'; +require_once __DIR__ . '/mail/Attachment.php'; +require_once __DIR__ . '/mail/BatchId.php'; +require_once __DIR__ . '/mail/Bcc.php'; +require_once __DIR__ . '/mail/BccSettings.php'; +require_once __DIR__ . '/mail/BypassListManagement.php'; +require_once __DIR__ . '/mail/Category.php'; +require_once __DIR__ . '/mail/Cc.php'; +require_once __DIR__ . '/mail/ClickTracking.php'; +require_once __DIR__ . '/mail/Content.php'; +require_once __DIR__ . '/mail/CustomArg.php'; +require_once __DIR__ . '/mail/Footer.php'; +require_once __DIR__ . '/mail/From.php'; +require_once __DIR__ . '/mail/Ganalytics.php'; +require_once __DIR__ . '/mail/GroupId.php'; +require_once __DIR__ . '/mail/GroupsToDisplay.php'; +require_once __DIR__ . '/mail/Header.php'; +require_once __DIR__ . '/mail/HtmlContent.php'; +require_once __DIR__ . '/mail/IpPoolName.php'; +require_once __DIR__ . '/mail/Mail.php'; +require_once __DIR__ . '/mail/MailSettings.php'; +require_once __DIR__ . '/mail/MimeType.php'; +require_once __DIR__ . '/mail/OpenTracking.php'; +require_once __DIR__ . '/mail/Personalization.php'; +require_once __DIR__ . '/mail/PlainTextContent.php'; +require_once __DIR__ . '/mail/ReplyTo.php'; +require_once __DIR__ . '/mail/Section.php'; +require_once __DIR__ . '/mail/SandBoxMode.php'; +require_once __DIR__ . '/mail/SendAt.php'; +require_once __DIR__ . '/mail/SpamCheck.php'; +require_once __DIR__ . '/mail/Subject.php'; +require_once __DIR__ . '/mail/SubscriptionTracking.php'; +require_once __DIR__ . '/mail/Substitution.php'; +require_once __DIR__ . '/mail/TemplateId.php'; +require_once __DIR__ . '/mail/TrackingSettings.php'; +require_once __DIR__ . '/mail/To.php'; +require_once __DIR__ . '/stats/Stats.php'; diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php deleted file mode 100755 index 94ede40..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env php -<?php - -/* - * From: http://raamdev.com/2008/amazon-s3-hmac-signatures-without-pear-or-php5/ - */ - -/* - * Calculate HMAC-SHA1 according to RFC2104 - * See http://www.faqs.org/rfcs/rfc2104.html - */ -function hmacsha1($key, $data) -{ - $blocksize = 64; - $hashfunc = 'sha1'; - if (strlen($key) > $blocksize) { - $key = pack('H*', $hashfunc($key)); - } - $key = str_pad($key, $blocksize, chr(0x00)); - $ipad = str_repeat(chr(0x36), $blocksize); - $opad = str_repeat(chr(0x5c), $blocksize); - $hmac = pack( - 'H*', $hashfunc( - ($key ^ $opad).pack( - 'H*', $hashfunc( - ($key ^ $ipad).$data - ) - ) - ) - ); - return bin2hex($hmac); -} - -/* - * Used to encode a field for Amazon Auth - * (taken from the Amazon S3 PHP example library) - */ -function hex2b64($str) -{ - $raw = ''; - for ($i = 0; $i < strlen($str); $i += 2) { - $raw .= chr(hexdec(substr($str, $i, 2))); - } - return base64_encode($raw); -} - -if (count($argv) != 3) { - echo "Usage: " . $argv[0] . " <S3 Policy File> <S3 secret key>\n"; - exit(1); -} - -$policy = file_get_contents($argv[1]); -$secret = $argv[2]; - -/* - * Base64 encode the Policy Document and then - * create HMAC SHA-1 signature of the base64 encoded policy - * using the secret key. Finally, encode it for Amazon Authentication. - */ -$base64_policy = base64_encode($policy); -$signature = hex2b64(hmacsha1($secret, $base64_policy)); -echo "S3_POLICY=\"" . $base64_policy . "\"\nS3_SIGNATURE=\"" . $signature . "\"\n" -?> diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json deleted file mode 100755 index 735e0b1..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "expiration": "2100-01-01T12:00:00.000Z", - "conditions": [ - {"acl": "public-read" }, - {"bucket": "sendgrid-open-source" }, - ["starts-with", "$key", "sendgrid-php/"], - ["content-length-range", 2048, 268435456], - ["eq", "$Content-Type", "application/zip"] - ] -} - diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh deleted file mode 100755 index 5d4a605..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# From: -# http://raamdev.com/2008/using-curl-to-upload-files-via-post-to-amazon-s3/ - -GIT_VERSION=`git rev-parse --short HEAD` - -rm -rf vendor composer.lock -composer install --no-dev -printf "<?php\nrequire __DIR__ . '/vendor/autoload.php';\n?>" > sendgrid-php.php -cd .. -zip -r sendgrid-php.zip sendgrid-php -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\* - -curl -X POST \ - -F "key=sendgrid-php/versions/sendgrid-php-$GIT_VERSION.zip" \ - -F "acl=public-read" \ - -F "AWSAccessKeyId=$S3_ACCESS_KEY" \ - -F "Policy=$S3_POLICY" \ - -F "Signature=$S3_SIGNATURE" \ - -F "Content-Type=application/zip" \ - -F "file=@./sendgrid-php.zip" \ - https://s3.amazonaws.com/$S3_BUCKET - -if [ "$TRAVIS_BRANCH" = "master" ] -then - curl -X POST \ - -F "key=sendgrid-php/sendgrid-php.zip" \ - -F "acl=public-read" \ - -F "AWSAccessKeyId=$S3_ACCESS_KEY" \ - -F "Policy=$S3_POLICY" \ - -F "Signature=$S3_SIGNATURE" \ - -F "Content-Type=application/zip" \ - -F "file=@./sendgrid-php.zip" \ - https://s3.amazonaws.com/$S3_BUCKET -fi - -exit 0 diff --git a/Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php b/Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php index 55b7d49..b569c98 100644 --- a/Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php +++ b/Postman/Postman-Send-Test-Email/PostmanSendTestEmailController.php @@ -13,7 +13,7 @@ class PostmanSendTestEmailController { /** * Constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath */ public function __construct( $rootPluginFilenameAndPath ) { assert( ! empty( $rootPluginFilenameAndPath ) ); @@ -90,7 +90,7 @@ class PostmanSendTestEmailController { * Register the Email Test screen */ public function addEmailTestSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ) ), __( 'Postman SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanSendTestEmailController::EMAIL_TEST_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Postman SMTP', 'post-smtp' ) ), __( 'Postman SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanSendTestEmailController::EMAIL_TEST_SLUG, array( $this, 'outputTestEmailContent', ) ); @@ -110,11 +110,11 @@ class PostmanSendTestEmailController { wp_enqueue_script( 'postman_test_email_wizard_script' ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_email_test', array( 'recipient' => '#' . self::RECIPIENT_EMAIL_FIELD_NAME, - 'not_started' => _x( 'In Outbox', 'Email Test Status', Postman::TEXT_DOMAIN ), - 'sending' => _x( 'Sending...', 'Email Test Status', Postman::TEXT_DOMAIN ), - 'success' => _x( 'Success', 'Email Test Status', Postman::TEXT_DOMAIN ), - 'failed' => _x( 'Failed', 'Email Test Status', Postman::TEXT_DOMAIN ), - 'ajax_error' => __( 'Ajax Error', Postman::TEXT_DOMAIN ), + 'not_started' => _x( 'In Outbox', 'Email Test Status', 'post-smtp' ), + 'sending' => _x( 'Sending...', 'Email Test Status', 'post-smtp' ), + 'success' => _x( 'Success', 'Email Test Status', 'post-smtp' ), + 'failed' => _x( 'Failed', 'Email Test Status', 'post-smtp' ), + 'ajax_error' => __( 'Ajax Error', 'post-smtp' ), ) ); } @@ -123,42 +123,42 @@ class PostmanSendTestEmailController { public function outputTestEmailContent() { print '<div class="wrap">'; - PostmanViewController::outputChildPageHeader( __( 'Send a Test Email', Postman::TEXT_DOMAIN ) ); + PostmanViewController::outputChildPageHeader( __( 'Send a Test Email', 'post-smtp' ) ); printf( '<form id="postman_test_email_wizard" method="post" action="%s">', PostmanUtils::getSettingsPageUrl() ); // Step 1 - printf( '<h5>%s</h5>', __( 'Specify the Recipient', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Specify the Recipient', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', __( 'Who is this message going to?', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s', __( 'This utility allows you to send an email message for testing.', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', __( 'Who is this message going to?', 'post-smtp' ) ); + printf( '<p>%s', __( 'This utility allows you to send an email message for testing.', 'post-smtp' ) ); print ' '; /* translators: where %d is an amount of time, in seconds */ - printf( '%s</p>', sprintf( _n( 'If there is a problem, Postman will give up after %d second.', 'If there is a problem, Postman will give up after %d seconds.', $this->options->getReadTimeout(), Postman::TEXT_DOMAIN ), $this->options->getReadTimeout() ) ); - printf( '<label for="postman_test_options[test_email]">%s</label>', _x( 'Recipient Email Address', 'Configuration Input Field', Postman::TEXT_DOMAIN ) ); + printf( '%s</p>', sprintf( _n( 'If there is a problem, Postman will give up after %d second.', 'If there is a problem, Postman will give up after %d seconds.', $this->options->getReadTimeout(), 'post-smtp' ), $this->options->getReadTimeout() ) ); + printf( '<label for="postman_test_options[test_email]">%s</label>', _x( 'Recipient Email Address', 'Configuration Input Field', 'post-smtp' ) ); print $this->test_email_callback(); print '</fieldset>'; // Step 2 - printf( '<h5>%s</h5>', __( 'Send The Message', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Send The Message', 'post-smtp' ) ); print '<fieldset>'; print '<legend>'; - print __( 'Sending the message:', Postman::TEXT_DOMAIN ); - printf( ' <span id="postman_test_message_status">%s</span>', _x( 'In Outbox', 'Email Test Status', Postman::TEXT_DOMAIN ) ); + print __( 'Sending the message:', 'post-smtp' ); + printf( ' <span id="postman_test_message_status">%s</span>', _x( 'In Outbox', 'Email Test Status', 'post-smtp' ) ); print '</legend>'; print '<section>'; - printf( '<p><label>%s</label></p>', __( 'Status', Postman::TEXT_DOMAIN ) ); + printf( '<p><label>%s</label></p>', __( 'Status', 'post-smtp' ) ); print '<textarea id="postman_test_message_error_message" readonly="readonly" cols="65" rows="4"></textarea>'; print '</section>'; print '</fieldset>'; // Step 3 - printf( '<h5>%s</h5>', __( 'Session Transcript', Postman::TEXT_DOMAIN ) ); + printf( '<h5>%s</h5>', __( 'Session Transcript', 'post-smtp' ) ); print '<fieldset>'; - printf( '<legend>%s</legend>', __( 'Examine the Session Transcript if you need to.', Postman::TEXT_DOMAIN ) ); - printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', Postman::TEXT_DOMAIN ) ); + printf( '<legend>%s</legend>', __( 'Examine the Session Transcript if you need to.', 'post-smtp' ) ); + printf( '<p>%s</p>', __( 'This is the conversation between Postman and the mail server. It can be useful for diagnosing problems. <b>DO NOT</b> post it on-line, it may contain your account password.', 'post-smtp' ) ); print '<section>'; - printf( '<p><label for="postman_test_message_transcript">%s</label></p>', __( 'Session Transcript', Postman::TEXT_DOMAIN ) ); + printf( '<p><label for="postman_test_message_transcript">%s</label></p>', __( 'Session Transcript', 'post-smtp' ) ); print '<textarea readonly="readonly" id="postman_test_message_transcript" cols="65" rows="8"></textarea>'; print '</section>'; print '</fieldset>'; @@ -206,7 +206,7 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler { $serverName = PostmanUtils::postmanGetServerName(); /* translators: where %s is the domain name of the site */ - $subject = sprintf( _x( 'Postman SMTP Test (%s)', 'Test Email Subject', Postman::TEXT_DOMAIN ), $serverName ); + $subject = sprintf( _x( 'Postman SMTP Test (%s)', 'Test Email Subject', 'post-smtp' ), $serverName ); // Postman API: indicate to Postman this is just for testing add_filter( 'postman_test_email', array( @@ -236,7 +236,7 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler { if ( $success ) { $this->logger->debug( 'Test Email delivered to server' ); // the message was sent successfully, generate an appropriate message for the user - $statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', Postman::TEXT_DOMAIN ), $result ['time'] ); + $statusMessage = sprintf( __( 'Your message was delivered (%d ms) to the SMTP server! Congratulations :)', 'post-smtp' ), $result ['time'] ); $this->logger->debug( 'statusmessage: ' . $statusMessage ); @@ -292,9 +292,9 @@ class PostmanSendTestEmailAjaxController extends PostmanAbstractAjaxHandler { // English - Mandarin - French - Hindi - Spanish - Portuguese - Russian - Japanese // http://www.pinyin.info/tools/converter/chars2uninumbers.html $greeting = 'Hello! - 你好 - Bonjour! - नमस्ते - ¡Hola! - Olá - Привет! - 今日は'; - $sentBy = sprintf( _x( 'Sent by Postman %s', 'Test Email Tagline', Postman::TEXT_DOMAIN ), $pluginData ['version'] ); - $imageSource = __( 'Image source', Postman::TEXT_DOMAIN ); - $withPermission = __( 'Used with permission', Postman::TEXT_DOMAIN ); + $sentBy = sprintf( _x( 'Sent by Postman %s', 'Test Email Tagline', 'post-smtp' ), $pluginData ['version'] ); + $imageSource = __( 'Image source', 'post-smtp' ); + $withPermission = __( 'Used with permission', 'post-smtp' ); $messageArray = array( 'Content-Type: text/plain; charset = "UTF-8"', 'Content-Transfer-Encoding: 8bit', diff --git a/Postman/Postman.php b/Postman/Postman.php index b0f70e0..1610da5 100644 --- a/Postman/Postman.php +++ b/Postman/Postman.php @@ -19,6 +19,14 @@ class Postman { const ADMINISTRATOR_ROLE_NAME = 'administrator'; const MANAGE_POSTMAN_CAPABILITY_NAME = 'manage_postman_smtp'; const MANAGE_POSTMAN_CAPABILITY_LOGS = 'manage_postman_logs'; + + /** + * Use the text domain directly instead of this constant, as it + * causes issues with https://translate.wordpress.org. + * + * @deprecated + * @see https://github.com/yehudah/Post-SMTP/issues/1#issuecomment-421940923 + */ const TEXT_DOMAIN = 'post-smtp'; private $logger; @@ -30,7 +38,7 @@ class Postman { /** * The constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath * - the __FILE__ of the caller */ public function __construct( $rootPluginFilenameAndPath, $version ) { @@ -56,11 +64,12 @@ class Postman { require_once 'Postman-Email-Log/PostmanEmailLogPostType.php'; require_once 'Postman-Mail/PostmanMyMailConnector.php'; require_once 'Postman-Mail/PostmanContactForm7.php'; + require_once 'Phpmailer/PostsmtpMailer.php'; //require_once 'Postman-Mail/PostmanWooCommerce.php'; // get plugin metadata - alternative to get_plugin_data $this->pluginData = array( - 'name' => __( 'Postman SMTP', Postman::TEXT_DOMAIN ), + 'name' => __( 'Postman SMTP', 'post-smtp' ), 'version' => $version, ); @@ -83,13 +92,21 @@ class Postman { // register the email transports $this->registerTransports( $rootPluginFilenameAndPath ); - // store an instance of the WpMailBinder - $this->wpMailBinder = PostmanWpMailBinder::getInstance(); + // store an instance of the WpMailBinder + $this->wpMailBinder = PostmanWpMailBinder::getInstance(); - // bind to wp_mail - this has to happen before the "init" action - // this design allows other plugins to register a Postman transport and call bind() - // bind may be called more than once - $this->wpMailBinder->bind(); + $mailer = PostmanOptions::getInstance()->getSmtpMailer(); + $this->logger->trace( 'SMTP Mailer: ' . $mailer ); + + if ( $mailer && $mailer !== 'phpmailer') { + + // bind to wp_mail - this has to happen before the "init" action + // this design allows other plugins to register a Postman transport and call bind() + // bind may be called more than once + $this->wpMailBinder->bind(); + } else { + PostmanWpMailBinder::getInstance()->bound = true; + } // registers the custom post type for all callers PostmanEmailLogPostType::automaticallyCreatePostType(); @@ -163,9 +180,9 @@ class Postman { public function post_smtp_wpml_admin_notice() { $class = 'notice notice-error'; - $title = __( 'Post SMTP notice!', Postman::TEXT_DOMAIN ); - $intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins - you better upgrade, but we can try to fix it.', Postman::TEXT_DOMAIN ); - $text = __( 'Click here to fix', Postman::TEXT_DOMAIN ); + $title = __( 'Post SMTP notice!', 'post-smtp' ); + $intro = __( 'WPML is installed and has a known bug with Post SMTP and few other plugins - you better upgrade, but we can try to fix it.', 'post-smtp' ); + $text = __( 'Click here to fix', 'post-smtp' ); $message = '<br><a href="' . esc_url( add_query_arg( 'action', 'postman_fix_wpml', get_permalink() ) ) . '">' . $text . '</a>'; printf( '<div class="%1$s"><h2>%2$s</h2><p>%3$s</p><p>%4$s</p></div>', esc_attr( $class ), $title, $intro, $message ); @@ -305,7 +322,8 @@ class Postman { // I've adopted their error message as well, for shits and giggles .... :D $reflFunc = new ReflectionFunction( 'wp_mail' ); - $message = __( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', Postman::TEXT_DOMAIN ); + $message = __( 'Postman: wp_mail has been declared by another plugin or theme, so you won\'t be able to use Postman until the conflict is resolved.', 'post-smtp' ); + $plugin_full_path = $reflFunc->getFileName(); if ( strpos( $plugin_full_path, 'plugins' ) !== false ) { @@ -323,6 +341,12 @@ class Postman { } $message .= '<br><strong>More info that may help</strong> - ' . $reflFunc->getFileName() . ':' . $reflFunc->getStartLine(); + + // PHPmailer Recommandation + ob_start(); + Postman::getMailerTypeRecommend(); + $message .= ob_get_clean(); + $this->messageHandler->addError( $message ); } } else { @@ -359,6 +383,25 @@ class Postman { } } + public static function getMailerTypeRecommend() { + ?> + <div> + <p style="font-size: 18px; font-weight: bold;">Please notice</p> + <p style="font-size: 14px; line-height: 1.7;"> + <?php _e('Post SMTP v2 includes and new feature called: <b>Mailer Type</b>.', 'post-smtp' ); ?><br> + <?php _e('I highly recommend to change and <strong>TEST</strong> Post SMTP with the value <code>PHPMailer</code>.', 'post-smtp' ); ?><br> + <?php _e('if it will not work properly you can change back to the default value: <code>PostSMTP</code>.', 'post-smtp' ); ?><br> + <a target="_blank" href="<?php echo POST_URL; ?>/style/images/mailer-type.gif"> + <figure> + <img width="180" src="<?php echo POST_URL; ?>/style/images/mailer-type.gif" alt="how to set mailer type"> + <figcaption><?php _e('click to enlarge image.', 'post-smtp' ); ?></figcaption> + </figure> + </a> + </p> + </div> + <?php + } + /** * Returns the plugin version number and name * Part of the Postman API @@ -382,8 +425,8 @@ class Postman { } $msg = PostmanTransportRegistry::getInstance()->getReadyMessage(); $message = sprintf( $msg['message'] ); - $goToSettings = sprintf( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', Postman::TEXT_DOMAIN ) ); - $goToEmailLog = sprintf( '%s', _x( 'Email Log', 'The log of Emails that have been delivered', Postman::TEXT_DOMAIN ) ); + $goToSettings = sprintf( '<a href="%s">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', 'post-smtp' ) ); + $goToEmailLog = sprintf( '%s', _x( 'Email Log', 'The log of Emails that have been delivered', 'post-smtp' ) ); if ( PostmanOptions::getInstance()->isMailLoggingEnabled() ) { $goToEmailLog = sprintf( '<a href="%s">%s</a>', PostmanUtils::getEmailLogPageUrl(), $goToEmailLog ); } @@ -404,15 +447,19 @@ class Postman { * The Gmail API used to be a separate plugin which was registered when that plugin * was loaded. But now both the SMTP, Gmail API and other transports are registered here. * - * @param unknown $pluginData + * @param mixed $pluginData */ private function registerTransports( $rootPluginFilenameAndPath ) { - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanDefaultModuleTransport( $rootPluginFilenameAndPath ) ); - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanSmtpModuleTransport( $rootPluginFilenameAndPath ) ); - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanGmailApiModuleTransport( $rootPluginFilenameAndPath ) ); - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanMandrillTransport( $rootPluginFilenameAndPath ) ); - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanSendGridTransport( $rootPluginFilenameAndPath ) ); - PostmanTransportRegistry::getInstance()->registerTransport( new PostmanMailgunTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry = PostmanTransportRegistry::getInstance(); + + $postman_transport_registry->registerTransport( new PostmanDefaultModuleTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry->registerTransport( new PostmanSmtpModuleTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry->registerTransport( new PostmanGmailApiModuleTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry->registerTransport( new PostmanMandrillTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry->registerTransport( new PostmanSendGridTransport( $rootPluginFilenameAndPath ) ); + $postman_transport_registry->registerTransport( new PostmanMailgunTransport( $rootPluginFilenameAndPath ) ); + + do_action( 'postsmtp_register_transport', $postman_transport_registry ); } /** @@ -433,12 +480,12 @@ class Postman { $shortLocale = substr( get_locale(), 0, 2 ); if ( $shortLocale != 'en' ) { $langDir = 'post-smtp/Postman/languages'; - $success = load_plugin_textdomain( Postman::TEXT_DOMAIN, false, $langDir ); + $success = load_plugin_textdomain( 'post-smtp', false, $langDir ); if ( $this->logger->isDebug() ) { if ( $success ) { $this->logger->debug( sprintf( 'local translation file loaded for locale=%s', get_locale() ) ); } else { - $this->logger->debug( sprintf( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale(), $langDir, Postman::TEXT_DOMAIN, get_locale() ) ); + $this->logger->debug( sprintf( 'failed to load local translation file: locale=%s file=%s/%s-%s.mo', get_locale(), $langDir, 'post-smtp', get_locale() ) ); } } } @@ -460,7 +507,7 @@ if ( ! function_exists( 'str_getcsv' ) ) { /** * PHP version less than 5.3 don't have str_getcsv natively. * - * @param unknown $string + * @param mixed $string * @return multitype: */ function str_getcsv( $string ) { diff --git a/Postman/PostmanAdminController.php b/Postman/PostmanAdminController.php index f85e30c..f92bc2c 100644 --- a/Postman/PostmanAdminController.php +++ b/Postman/PostmanAdminController.php @@ -78,7 +78,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { /** * Constructor * - * @param unknown $rootPluginFilenameAndPath + * @param mixed $rootPluginFilenameAndPath * @param PostmanOptions $options * @param PostmanOAuthToken $authorizationToken * @param PostmanMessageHandler $messageHandler @@ -111,7 +111,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { // do a redirect on the init hook $this->registerInitFunction( 'handleSuccessfulSave' ); // add a saved message to be shown after the redirect - $this->messageHandler->addMessage( _x( 'Settings saved.', 'The plugin successfully saved new settings.', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addMessage( _x( 'Settings saved.', 'The plugin successfully saved new settings.', 'post-smtp' ) ); return; } else { // unset the action in the failed case as well @@ -162,11 +162,11 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { ?> <input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_global_settings]" value="null"> <input type="hidden" name="<?php echo PostmanOptions::POSTMAN_NETWORK_OPTIONS; ?>[post_smtp_allow_overwrite]" value="null"> - <h2><?php _e( 'Post SMTP Settings', Postman::TEXT_DOMAIN ); ?></h2> + <h2><?php _e( 'Post SMTP Settings', 'post-smtp' ); ?></h2> <table id="menu" class="form-table"> <tr> <th scope="row"> - <?php _e( 'Enable global settings', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'Enable global settings', 'post-smtp' ); ?> </th> <td> <?php $checked = checked( $options['post_smtp_global_settings'], 1, false ); ?> @@ -177,14 +177,14 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { <?php echo $checked; ?> > <p class="description"> - <?php _e('Same settings as the main site/blog (id:1)', Postman::TEXT_DOMAIN ); ?> + <?php _e('Same settings as the main site/blog (id:1)', 'post-smtp' ); ?> </p> </label> </td> </tr> <tr> <th scope="row"> - <?php _e( 'Allow user to load saved options', Postman::TEXT_DOMAIN ); ?> + <?php _e( 'Allow user to load saved options', 'post-smtp' ); ?> </th> <td> <?php $checked = checked( $options['post_smtp_allow_overwrite'], 1, false ); ?> @@ -252,7 +252,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { foreach ( $states as $state ) { if ( ! $state ['ready'] ) { /* Translators: where %1$s is the name of the library */ - $message = sprintf( __( 'This PHP installation requires the <b>%1$s</b> library.', Postman::TEXT_DOMAIN ), $state ['name'] ); + $message = sprintf( __( 'This PHP installation requires the <b>%1$s</b> library.', 'post-smtp' ), $state ['name'] ); if ( $state ['required'] ) { $this->messageHandler->addError( $message ); } else { @@ -264,8 +264,8 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ private function registerInitFunction( $callbackName ) { $this->logger->debug( 'Registering init function ' . $callbackName ); @@ -278,8 +278,8 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { /** * Registers actions posted by am HTML FORM with the WordPress 'action' parameter * - * @param unknown $actionName - * @param unknown $callbankName + * @param mixed $actionName + * @param mixed $callbankName */ private function registerAdminPostAction( $actionName, $callbankName ) { // $this->logger->debug ( 'Registering ' . $actionName . ' Action Post handler' ); @@ -292,15 +292,16 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { /** * Add "Settings" link to the plugin action page * - * @param unknown $links + * @param mixed $links * @return multitype: */ public function postmanModifyLinksOnPluginsListPage( $links ) { // only administrators should be able to trigger this if ( PostmanUtils::isAdmin() ) { $mylinks = array( - sprintf( '<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', Postman::TEXT_DOMAIN ) ), - sprintf( '<a href="%s" class="postman_settings">%s</a>', 'https://postmansmtp.com', __( 'Visit us', Postman::TEXT_DOMAIN ) ), + sprintf( '<a href="%s" target="_blank" class="postman_settings">%s</a>', 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yehuda@myinbox.in&item_name=Donation+for+PostSMTP', __( 'Donate', 'post-smtp' ) ), + sprintf( '<a href="%s" class="postman_settings">%s</a>', PostmanUtils::getSettingsPageUrl(), __( 'Settings', 'post-smtp' ) ), + sprintf( '<a href="%s" class="postman_settings">%s</a>', 'https://postmansmtp.com', __( 'Visit us', 'post-smtp' ) ), ); return array_merge( $mylinks, $links ); } @@ -328,7 +329,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { $success = false; } if ( ! $success ) { - $this->messageHandler->addError( __( 'There was an error importing the data.', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addError( __( 'There was an error importing the data.', 'post-smtp' ) ); $this->logger->error( 'There was an error importing the data' ); } PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL ); @@ -345,7 +346,7 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { delete_option( PostmanAdminController::TEST_OPTIONS ); $logPurger = new PostmanEmailLogPurger(); $logPurger->removeAll(); - $this->messageHandler->addMessage( __( 'Plugin data was removed.', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addMessage( __( 'Plugin data was removed.', 'post-smtp' ) ); PostmanUtils::redirect( PostmanUtils::POSTMAN_HOME_PAGE_RELATIVE_URL ); } } @@ -369,16 +370,16 @@ if ( ! class_exists( 'PostmanAdminController' ) ) { $logger->debug( 'Authorization successful' ); // save to database $authorizationToken->save(); - $this->messageHandler->addMessage( __( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addMessage( __( 'The OAuth 2.0 authorization was successful. Ready to send e-mail.', 'post-smtp' ) ); } else { - $this->messageHandler->addError( __( 'Your email provider did not grant Postman permission. Try again.', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addError( __( 'Your email provider did not grant Postman permission. Try again.', 'post-smtp' ) ); } } catch ( PostmanStateIdMissingException $e ) { - $this->messageHandler->addError( __( 'The grant code from Google had no accompanying state and may be a forgery', Postman::TEXT_DOMAIN ) ); + $this->messageHandler->addError( __( 'The grant code from Google had no accompanying state and may be a forgery', 'post-smtp' ) ); } catch ( Exception $e ) { $logger->error( 'Error: ' . get_class( $e ) . ' code=' . $e->getCode() . ' message=' . $e->getMessage() ); /* translators: %s is the error message */ - $this->messageHandler->addError( sprintf( __( 'Error authenticating with this Client ID. [%s]', Postman::TEXT_DOMAIN ), '<em>' . $e->getMessage() . '</em>' ) ); + $this->messageHandler->addError( sprintf( __( 'Error authenticating with this Client ID. [%s]', 'post-smtp' ), '<em>' . $e->getMessage() . '</em>' ) ); } // clean-up diff --git a/Postman/PostmanAjaxController.php b/Postman/PostmanAjaxController.php index caa23e9..88ec369 100644 --- a/Postman/PostmanAjaxController.php +++ b/Postman/PostmanAjaxController.php @@ -15,8 +15,8 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) { } /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ protected function registerAjaxHandler($actionName, $class, $callbackName) { if (is_admin ()) { @@ -31,7 +31,7 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) { /** * - * @param unknown $parameterName + * @param mixed $parameterName * @return mixed */ protected function getBooleanRequestParameter($parameterName) { @@ -40,8 +40,8 @@ if (! class_exists ( 'PostmanAbstractAjaxHandler' )) { /** * - * @param unknown $parameterName - * @return unknown + * @param mixed $parameterName + * @return mixed */ protected function getRequestParameter($parameterName) { if (isset ( $_POST [$parameterName] )) { diff --git a/Postman/PostmanConfigTextHelper.php b/Postman/PostmanConfigTextHelper.php index bcae7f5..6bc23fe 100644 --- a/Postman/PostmanConfigTextHelper.php +++ b/Postman/PostmanConfigTextHelper.php @@ -28,8 +28,8 @@ if ( ! class_exists( 'PostmanAbstractConfigTextHelper' ) ) { */ abstract class PostmanAbstractConfigTextHelper implements PostmanConfigTextHelper { public function getOAuthHelp() { - $attention = __( 'Attention', Postman::TEXT_DOMAIN ); - $errorMessage = sprintf( __('Check this article how to configure Gmail/Gsuite OAuth:<a href="%1$s" target="_blank">Read Here</a>', Postman::TEXT_DOMAIN ), 'https://postmansmtp.com/how-to-configure-post-smtp-with-gmailgsuite-using-oauth/' ); + $attention = __( 'Attention', 'post-smtp' ); + $errorMessage = sprintf( __('Check this article how to configure Gmail/Gsuite OAuth:<a href="%1$s" target="_blank">Read Here</a>', 'post-smtp' ), 'https://postmansmtp.com/how-to-configure-post-smtp-with-gmailgsuite-using-oauth/' ); $text = sprintf( '<b style="color:red">%s!</b> %s', $attention, $errorMessage ); return $text; @@ -48,7 +48,7 @@ if ( ! class_exists( 'PostmanAbstractConfigTextHelper' ) ) { } public function getRequestPermissionLinkText() { /* translators: where %s is the Email Service Owner (e.g. Google, Microsoft or Yahoo) */ - return sprintf( _x( 'Grant permission with %s', 'Command to initiate OAuth authentication', Postman::TEXT_DOMAIN ), $this->getOwnerName() ); + return sprintf( _x( 'Grant permission with %s', 'Command to initiate OAuth authentication', 'post-smtp' ), $this->getOwnerName() ); } } } @@ -74,35 +74,35 @@ if ( ! class_exists( 'PostmanGoogleOAuthScribe' ) ) { } public function getClientIdLabel() { /* Translators: This description is specific to Google */ - return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN ); + return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' ); } public function getClientSecretLabel() { /* Translators: This description is specific to Google */ - return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN ); + return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' ); } public function getCallbackUrlLabel() { /* Translators: This description is specific to Google */ - return _x( 'Authorized redirect URI', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN ); + return _x( 'Authorized redirect URI', 'Name of the Application Callback URI', 'post-smtp' ); } public function getCallbackDomainLabel() { /* Translators: This description is specific to Google */ - return _x( 'Authorized JavaScript origins', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN ); + return _x( 'Authorized JavaScript origins', 'Name of the Application Callback Domain', 'post-smtp' ); } public function getOwnerName() { /* Translators: This description is specific to Google */ - return _x( 'Google', 'Name of the email service owner', Postman::TEXT_DOMAIN ); + return _x( 'Google', 'Name of the email service owner', 'post-smtp' ); } public function getServiceName() { /* Translators: This description is specific to Google */ - return _x( 'Gmail', 'Name of the email service', Postman::TEXT_DOMAIN ); + return _x( 'Gmail', 'Name of the email service', 'post-smtp' ); } public function getApplicationDescription() { /* Translators: This description is specific to Google */ - return _x( 'a Client ID for web application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN ); + return _x( 'a Client ID for web application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' ); } public function getApplicationPortalName() { /* Translators: This description is specific to Google */ - return _x( 'Google Developers Console Gmail Wizard', 'Name of the email service portal', Postman::TEXT_DOMAIN ); + return _x( 'Google Developers Console Gmail Wizard', 'Name of the email service portal', 'post-smtp' ); } public function getApplicationPortalUrl() { return 'https://www.google.com/accounts/Logout?continue=https://console.developers.google.com/start/api?id=gmail'; @@ -136,35 +136,35 @@ if ( ! class_exists( 'PostmanMicrosoftOAuthScribe' ) ) { } public function getClientIdLabel() { /* Translators: This description is specific to Microsoft */ - return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN ); + return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' ); } public function getClientSecretLabel() { /* Translators: This description is specific to Microsoft */ - return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN ); + return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' ); } public function getCallbackUrlLabel() { /* Translators: This description is specific to Microsoft */ - return _x( 'Redirect URL', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN ); + return _x( 'Redirect URL', 'Name of the Application Callback URI', 'post-smtp' ); } public function getCallbackDomainLabel() { /* Translators: This description is specific to Microsoft */ - return _x( 'Root Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN ); + return _x( 'Root Domain', 'Name of the Application Callback Domain', 'post-smtp' ); } public function getOwnerName() { /* Translators: This description is specific to Microsoft */ - return _x( 'Microsoft', 'Name of the email service owner', Postman::TEXT_DOMAIN ); + return _x( 'Microsoft', 'Name of the email service owner', 'post-smtp' ); } public function getServiceName() { /* Translators: This description is specific to Microsoft */ - return _x( 'Outlook.com', 'Name of the email service', Postman::TEXT_DOMAIN ); + return _x( 'Outlook.com', 'Name of the email service', 'post-smtp' ); } public function getApplicationDescription() { /* Translators: This description is specific to Microsoft */ - return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN ); + return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' ); } public function getApplicationPortalName() { /* Translators: This description is specific to Microsoft */ - return _x( 'Microsoft Developer Center', 'Name of the email service portal', Postman::TEXT_DOMAIN ); + return _x( 'Microsoft Developer Center', 'Name of the email service portal', 'post-smtp' ); } public function getApplicationPortalUrl() { return 'https://account.live.com/developers/applications/index'; @@ -198,35 +198,35 @@ if ( ! class_exists( 'PostmanYahooOAuthScribe' ) ) { } public function getClientIdLabel() { /* Translators: This description is specific to Yahoo */ - return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN ); + return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' ); } public function getClientSecretLabel() { /* Translators: This description is specific to Yahoo */ - return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN ); + return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' ); } public function getCallbackUrlLabel() { /* Translators: This description is specific to Yahoo */ - return _x( 'Home Page URL', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN ); + return _x( 'Home Page URL', 'Name of the Application Callback URI', 'post-smtp' ); } public function getCallbackDomainLabel() { /* Translators: This description is specific to Yahoo */ - return _x( 'Callback Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN ); + return _x( 'Callback Domain', 'Name of the Application Callback Domain', 'post-smtp' ); } public function getOwnerName() { /* Translators: This description is specific to Yahoo */ - return _x( 'Yahoo', 'Name of the email service owner', Postman::TEXT_DOMAIN ); + return _x( 'Yahoo', 'Name of the email service owner', 'post-smtp' ); } public function getServiceName() { /* Translators: This description is specific to Yahoo */ - return _x( 'Yahoo Mail', 'Name of the email service', Postman::TEXT_DOMAIN ); + return _x( 'Yahoo Mail', 'Name of the email service', 'post-smtp' ); } public function getApplicationDescription() { /* Translators: This description is specific to Yahoo */ - return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN ); + return _x( 'an Application', 'Description of the email service OAuth 2.0 Application', 'post-smtp' ); } public function getApplicationPortalName() { /* Translators: This description is specific to Yahoo */ - return _x( 'Yahoo Developer Network', 'Name of the email service portal', Postman::TEXT_DOMAIN ); + return _x( 'Yahoo Developer Network', 'Name of the email service portal', 'post-smtp' ); } public function getApplicationPortalUrl() { return 'https://developer.yahoo.com/apps/'; @@ -255,7 +255,7 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) { return PostmanUtils::endsWith( $this->hostname, 'yahoo.com' ); } public function getOAuthHelp() { - $text = __( 'Enter an Outgoing Mail Server with OAuth2 capabilities.', Postman::TEXT_DOMAIN ); + $text = __( 'Enter an Outgoing Mail Server with OAuth2 capabilities.', 'post-smtp' ); return sprintf( '<span style="color:red" class="normal">%s</span>', $text ); } public function getCallbackUrl() { @@ -265,16 +265,16 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) { return ''; } public function getClientIdLabel() { - return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN ); + return _x( 'Client ID', 'Name of the OAuth 2.0 Client ID', 'post-smtp' ); } public function getClientSecretLabel() { - return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN ); + return _x( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', 'post-smtp' ); } public function getCallbackUrlLabel() { - return _x( 'Redirect URI', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN ); + return _x( 'Redirect URI', 'Name of the Application Callback URI', 'post-smtp' ); } public function getCallbackDomainLabel() { - return _x( 'Website Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN ); + return _x( 'Website Domain', 'Name of the Application Callback Domain', 'post-smtp' ); } public function getOwnerName() { return ''; @@ -298,7 +298,7 @@ if ( ! class_exists( 'PostmanNonOAuthScribe' ) ) { return ''; } public function getRequestPermissionLinkText() { - return __( 'Grant OAuth 2.0 Permission', Postman::TEXT_DOMAIN ); + return __( 'Grant OAuth 2.0 Permission', 'post-smtp' ); } } } diff --git a/Postman/PostmanEmailLogs.php b/Postman/PostmanEmailLogs.php new file mode 100644 index 0000000..c7b6175 --- /dev/null +++ b/Postman/PostmanEmailLogs.php @@ -0,0 +1,111 @@ +<?php + +class PostmanEmailLogs { + + private $db; + + public $db_name = 'post_smtp_logs'; + + private static $fields = array( + 'success', + 'from_header', + 'to_header', + 'cc_header', + 'bcc_header', + 'reply_to_header', + 'transport_uri', + 'original_to', + 'original_subject', + 'original_message', + 'original_headers', + 'session_transcript' + ); + + private static $instance; + + public static function get_instance() { + if ( ! self::$instance ) { + self::$instanc = new static(); + } + + return self::$instance; + } + + private function __construct() { + global $wpdb; + + $this->db = $wpdb; + } + + function install_table() { + + global $wpdb; + + $sql = "CREATE TABLE `{$wpdb->prefix}_{$this->db_name}` (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
"; + + foreach ($this->fields as $field ) { + if ( $field == 'original_message' || $field == 'session_transcript' ) { + $sql .= "`" . $field . "` longtext DEFAULT NULL,"; + continue; + } + $sql .= "`" . $field . "` varchar(255) DEFAULT NULL,"; + } + $sql .= "PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET={$wpdb->charset} COLLATE={$wpdb->collate};
"; + + dbDelta( $sql ); + } + + public static function get_data( $post_id ) { + $fields = array(); + foreach ( self::$fields as $field ) { + $fields[$field][0] = get_post_meta( $post_id, $field, true ); + } + + return $fields; + } + + public static function get_fields() { + return self::$fields; + } + + function migrate_data() { + $args = array( + 'post_type' => 'postman_sent_mail', + 'posts_per_page' => -1, + ); + + $logs = new WP_Query($args); + + $failed_records = 0; + foreach ( $logs->posts as $log ) { + + foreach ($this->fields as $key ) { + $value = $this->get_meta( $log->ID, $key, true ); + + if ( $this->add_meta( $log->ID, $key, $value ) ) { + delete_post_meta( $log->ID, $key ); + } else { + $failed_records++; + } + } + } + } + + function load() { + $this->db->select(); + } + + /** + * @param array $data + */ + function save( $data ) { + $this->db->query( $this->db->prepare( + " + INSERT INTO $this->db_name + ( " . implode( ',', array_keys( $data ) ) . " ) + VALUES ( " . str_repeat( '%s', count( $data ) ) . " )", array_values( $data ) + ) ); + } + +}
\ No newline at end of file diff --git a/Postman/PostmanInputSanitizer.php b/Postman/PostmanInputSanitizer.php index 6a4f442..561ce28 100644 --- a/Postman/PostmanInputSanitizer.php +++ b/Postman/PostmanInputSanitizer.php @@ -40,6 +40,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) { $new_input [ PostmanOptions::ENVELOPE_SENDER ] = $new_input [ PostmanOptions::MESSAGE_SENDER_EMAIL ]; $this->sanitizeString( 'Sender Email', PostmanOptions::ENVELOPE_SENDER, $input, $new_input ); $this->sanitizeString( 'Transport Type', PostmanOptions::TRANSPORT_TYPE, $input, $new_input ); + $this->sanitizeString( 'SMTP Mailers', 'smtp_mailers', $input, $new_input ); $this->sanitizeString( 'Authorization Type', PostmanOptions::AUTHENTICATION_TYPE, $input, $new_input ); $this->sanitizeString( 'From Name', PostmanOptions::MESSAGE_SENDER_NAME, $input, $new_input ); $this->sanitizeString( 'Client ID', PostmanOptions::CLIENT_ID, $input, $new_input ); @@ -121,10 +122,10 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) { /** * Sanitize a Basic Auth password, and base64-encode it * - * @param unknown $desc - * @param unknown $key - * @param unknown $input - * @param unknown $new_input + * @param mixed $desc + * @param mixed $key + * @param mixed $input + * @param mixed $new_input */ private function sanitizePassword( $desc, $key, $input, &$new_input, $existingPassword ) { // WordPress calling Sanitize twice is a known issue @@ -157,7 +158,7 @@ if ( ! class_exists( 'PostmanInputSanitizer' ) ) { if ( $value <= 0 ) { $new_input [ $key ] = PostmanOptions::getInstance()->getMailLoggingMaxEntries(); $h = new PostmanMessageHandler(); - $h->addError( sprintf( '%s %s', __( 'Maximum Log Entries', Postman::TEXT_DOMAIN ), __( 'must be greater than 0', Postman::TEXT_DOMAIN ) ) ); + $h->addError( sprintf( '%s %s', __( 'Maximum Log Entries', 'post-smtp' ), __( 'must be greater than 0', 'post-smtp' ) ) ); } else { $this->logSanitize( $desc, $input [ $key ] ); $new_input [ $key ] = $value; diff --git a/Postman/PostmanInstaller.php b/Postman/PostmanInstaller.php index f011251..0563679 100644 --- a/Postman/PostmanInstaller.php +++ b/Postman/PostmanInstaller.php @@ -24,6 +24,9 @@ class PostmanInstaller { * Handle activation of the plugin */ public function activatePostman() { + delete_option( 'postman_release_version' ); + delete_option( 'postman_dismiss_donation' ); + $options = get_option( PostmanOptions::POSTMAN_OPTIONS ); $args = array( 'fallback_smtp_enabled' => 'no', @@ -41,10 +44,6 @@ class PostmanInstaller { if ( function_exists( 'is_multisite' ) && is_multisite() ) { -/* $role = get_role( Postman::ADMINISTRATOR_ROLE_NAME ); - $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_NAME ); - $role->add_cap( Postman::MANAGE_POSTMAN_CAPABILITY_LOGS );*/ - $options['post_smtp_allow_overwrite'] = '1'; update_site_option( PostmanOptions::POSTMAN_NETWORK_OPTIONS, $options ); diff --git a/Postman/PostmanLogger.php b/Postman/PostmanLogger.php index e57960b..c606e25 100644 --- a/Postman/PostmanLogger.php +++ b/Postman/PostmanLogger.php @@ -44,8 +44,8 @@ if (! class_exists ( "PostmanLogger" )) { /** * better logging thanks to http://www.smashingmagazine.com/2011/03/08/ten-things-every-wordpress-plugin-developer-should-know/ * - * @param unknown $intLogLevel - * @param unknown $logLevelName + * @param mixed $intLogLevel + * @param mixed $logLevelName */ private function printLog($text, $intLogLevel, $logLevelName) { if ($this->wpDebug && $intLogLevel >= $this->logLevel) { diff --git a/Postman/PostmanMessageHandler.php b/Postman/PostmanMessageHandler.php index e592369..7a218e8 100644 --- a/Postman/PostmanMessageHandler.php +++ b/Postman/PostmanMessageHandler.php @@ -12,7 +12,7 @@ if (! class_exists ( 'PostmanMessageHandler' )) { /** * - * @param unknown $options + * @param mixed $options */ function __construct() { $this->logger = new PostmanLogger ( get_class ( $this ) ); @@ -26,21 +26,21 @@ if (! class_exists ( 'PostmanMessageHandler' )) { /** * - * @param unknown $message + * @param mixed $message */ public function addError($message) { $this->storeMessage ( $message, 'error' ); } /** * - * @param unknown $message + * @param mixed $message */ public function addWarning($message) { $this->storeMessage ( $message, 'warning' ); } /** * - * @param unknown $message + * @param mixed $message */ public function addMessage($message) { $this->storeMessage ( $message, 'notify' ); @@ -49,8 +49,8 @@ if (! class_exists ( 'PostmanMessageHandler' )) { /** * store messages for display later * - * @param unknown $message - * @param unknown $type + * @param mixed $message + * @param mixed $type */ private function storeMessage($message, $type) { $messageArray = array (); @@ -102,8 +102,8 @@ if (! class_exists ( 'PostmanMessageHandler' )) { /** * putput message * - * @param unknown $message - * @param unknown $className + * @param mixed $message + * @param mixed $className */ public function printMessage($message, $className) { printf ( '<div class="%s"><p>%s</p></div>', $className, $message ); diff --git a/Postman/PostmanOptions.php b/Postman/PostmanOptions.php index b6eaaf4..7d8c2a0 100644 --- a/Postman/PostmanOptions.php +++ b/Postman/PostmanOptions.php @@ -138,6 +138,11 @@ if ( ! class_exists( 'PostmanOptions' ) ) { const DEFAULT_PLUGIN_MESSAGE_SENDER_EMAIL_ENFORCED = false; const DEFAULT_TEMP_DIRECTORY = '/tmp'; + const SMTP_MAILERS = [ + 'phpmailer' => 'PHPMailer', + 'postsmtp' => 'PostSMTP' + ]; + public $is_fallback = false; // options data @@ -174,10 +179,9 @@ if ( ! class_exists( 'PostmanOptions' ) ) { if ( is_multisite() ) { $network_options = get_site_option( self::POSTMAN_NETWORK_OPTIONS ); + $blog_id = get_current_blog_id(); if ( isset( $network_options['post_smtp_global_settings'] ) ) { $blog_id = apply_filters( 'post_smtp_default_site_option', 1 ); - } elseif ( $options && isset( $network_options['post_smtp_allow_overwrite'] ) ) { - $blog_id = get_current_blog_id(); } switch_to_blog($blog_id); @@ -570,6 +574,15 @@ if ( ! class_exists( 'PostmanOptions' ) ) { $this->setSenderName( $senderName ); } } + + public function getSmtpMailer() { + if ( empty($this->options [ 'smtp_mailers' ]) ) { + return 'postsmtp'; + } + + return $this->options [ 'smtp_mailers' ]; + } + public function isAuthTypePassword() { return $this->isAuthTypeLogin() || $this->isAuthTypeCrammd5() || $this->isAuthTypePlain(); } @@ -604,7 +617,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) { * @see PostmanOptionsInterface::getSenderEmail() */ public function getSenderName() { - return $this->getMessageNameEmail(); + return $this->getMessageSenderName(); } /** @@ -625,7 +638,7 @@ if ( ! class_exists( 'PostmanOptions' ) ) { /** * - * @param unknown $data + * @param mixed $data */ public function import( $data ) { if ( PostmanPreRequisitesCheck::checkZlibEncode() ) { diff --git a/Postman/PostmanSession.php b/Postman/PostmanSession.php index 115c852..4243f2b 100644 --- a/Postman/PostmanSession.php +++ b/Postman/PostmanSession.php @@ -37,7 +37,7 @@ if (! class_exists ( 'PostmanSession' )) { * OAuth is in progress $state is the randomly generated * transaction ID * - * @param unknown $state + * @param mixed $state */ public function isSetOauthInProgress() { return get_transient ( self::OAUTH_IN_PROGRESS ) != false; @@ -55,7 +55,7 @@ if (! class_exists ( 'PostmanSession' )) { /** * Sometimes I need to keep track of what I'm doing between requests * - * @param unknown $action + * @param mixed $action */ public function isSetAction() { return get_transient ( self::ACTION ) != false; @@ -73,7 +73,7 @@ if (! class_exists ( 'PostmanSession' )) { /** * Sometimes I need to keep track of what I'm doing between requests * - * @param unknown $message + * @param mixed $message */ public function isSetErrorMessage() { return get_transient ( self::ERROR_MESSAGE ) != false; diff --git a/Postman/PostmanUtils.php b/Postman/PostmanUtils.php index 8c7081f..6858fe3 100644 --- a/Postman/PostmanUtils.php +++ b/Postman/PostmanUtils.php @@ -32,7 +32,7 @@ class PostmanUtils { /** * - * @param unknown $slug + * @param mixed $slug * @return string */ public static function getPageUrl( $slug ) { @@ -71,8 +71,8 @@ class PostmanUtils { /** * from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php * - * @param unknown $haystack - * @param unknown $needle + * @param mixed $haystack + * @param mixed $needle * @return boolean */ public static function startsWith( $haystack, $needle ) { @@ -82,8 +82,8 @@ class PostmanUtils { /** * from http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php * - * @param unknown $haystack - * @param unknown $needle + * @param mixed $haystack + * @param mixed $needle * @return boolean */ public static function endsWith( $haystack, $needle ) { @@ -99,8 +99,8 @@ class PostmanUtils { /** * Detect if the host is NOT a domain name * - * @param unknown $ipAddress - * @return number + * @param mixed $ipAddress + * @return bool */ public static function isHostAddressNotADomainName( $host ) { // IPv4 / IPv6 test from http://stackoverflow.com/a/17871737/4368109 @@ -115,9 +115,9 @@ class PostmanUtils { * Inside WordPress we can use wp_remote_post(). * Outside WordPress, not so much. * - * @param unknown $url - * @param unknown $args - * @return the HTML body + * @param mixed $url + * @param mixed $args + * @return string the HTML body */ static function remotePostGetBodyOnly( $url, $parameters, array $headers = array() ) { $response = PostmanUtils::remotePost( $url, $parameters, $headers ); @@ -130,9 +130,9 @@ class PostmanUtils { * Inside WordPress we can use wp_remote_post(). * Outside WordPress, not so much. * - * @param unknown $url - * @param unknown $args - * @return the HTTP response + * @param mixed $url + * @param mixed $args + * @return array|WP_Error the HTTP response */ static function remotePost( $url, $parameters = array(), array $headers = array() ) { $args = array( @@ -161,7 +161,7 @@ class PostmanUtils { * A facade function that handles redirects. * Inside WordPress we can use wp_redirect(). Outside WordPress, not so much. **Load it before postman-core.php** * - * @param unknown $url + * @param mixed $url */ static function redirect( $url ) { // redirections back to THIS SITE should always be relative because of IIS bug @@ -182,7 +182,7 @@ class PostmanUtils { * Rounds the bytes returned from memory_get_usage to smaller amounts used IEC binary prefixes * See http://en.wikipedia.org/wiki/Binary_prefix * - * @param unknown $size + * @param mixed $size * @return string */ static function roundBytes( $size ) { @@ -261,7 +261,7 @@ class PostmanUtils { /** * Creates the pathname of the lockfile * - * @param unknown $tempDirectory + * @param mixed $tempDirectory * @return string */ private static function calculateTemporaryLockPath( $tempDirectory ) { @@ -290,7 +290,7 @@ class PostmanUtils { /** * From http://stackoverflow.com/a/381275/4368109 * - * @param unknown $text + * @param mixed $text * @return boolean */ public static function isEmpty( $text ) { @@ -324,8 +324,8 @@ class PostmanUtils { /** * Validate an e-mail address * - * @param unknown $email - * @return number + * @param mixed $email + * @return string|bool */ static function validateEmail( $email ) { if ( PostmanOptions::getInstance()->isEmailValidationDisabled() ) { @@ -348,7 +348,7 @@ class PostmanUtils { /** * From http://stackoverflow.com/questions/13430120/str-getcsv-alternative-for-older-php-version-gives-me-an-empty-array-at-the-e * - * @param unknown $string + * @param mixed $string * @return multitype: */ static function postman_strgetcsv_impl( $string ) { @@ -364,7 +364,7 @@ class PostmanUtils { /** * - * @return Ambigous <string, unknown> + * @return string|mixed */ static function postmanGetServerName() { if ( ! empty( $_SERVER ['SERVER_NAME'] ) ) { @@ -380,7 +380,7 @@ class PostmanUtils { /** * Does this hostname belong to Google? * - * @param unknown $hostname + * @param mixed $hostname * @return boolean */ static function isGoogle( $hostname ) { @@ -389,8 +389,8 @@ class PostmanUtils { /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ public static function registerAdminMenu( $viewController, $callbackName ) { $logger = PostmanUtils::$logger; @@ -406,8 +406,8 @@ class PostmanUtils { /** * - * @param unknown $actionName - * @param unknown $callbackName + * @param mixed $actionName + * @param mixed $callbackName */ public static function registerAjaxHandler( $actionName, $class, $callbackName ) { if ( is_admin() ) { @@ -422,7 +422,7 @@ class PostmanUtils { /** * - * @param unknown $parameterName + * @param mixed $parameterName * @return mixed */ public static function getBooleanRequestParameter( $parameterName ) { @@ -431,8 +431,8 @@ class PostmanUtils { /** * - * @param unknown $parameterName - * @return unknown + * @param mixed $parameterName + * @return mixed */ public static function getRequestParameter( $parameterName ) { $logger = PostmanUtils::$logger; @@ -447,7 +447,7 @@ class PostmanUtils { } public static function getServerName() { - $result = 'localhost.localdomain'; + $host = 'localhost'; if (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { $host = $_SERVER['SERVER_NAME']; @@ -457,13 +457,6 @@ class PostmanUtils { $host = php_uname('n'); } - // as final option - if ip returned or hostname without extension (not valid dns name) - $extension = pathinfo( $host, PATHINFO_EXTENSION ); - if ( filter_var( $result, FILTER_VALIDATE_IP ) || empty( $extension ) ) { - $siteurl = get_bloginfo('url'); - $host = parse_url($siteurl, PHP_URL_HOST); - } - return str_replace('www.', '', $host ); } diff --git a/Postman/PostmanViewController.php b/Postman/PostmanViewController.php index 6fef916..8dffa31 100644 --- a/Postman/PostmanViewController.php +++ b/Postman/PostmanViewController.php @@ -38,6 +38,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { add_action( 'admin_init', array( $this, 'registerStylesAndScripts' ), 0 ); add_action( 'wp_ajax_delete_lock_file', array( $this, 'delete_lock_file' ) ); add_action( 'wp_ajax_dismiss_version_notify', array( $this, 'dismiss_version_notify' ) ); + add_action( 'wp_ajax_dismiss_donation_notify', array( $this, 'dismiss_donation_notify' ) ); //add_action( 'admin_init', array( $this, 'do_activation_redirect' ) ); @@ -47,19 +48,24 @@ if ( ! class_exists( 'PostmanViewController' ) ) { function dismiss_version_notify() { check_ajax_referer( 'postsmtp', 'security' ); - $version = sanitize_text_field($_POST['version']); - $result = update_option('postman_release_version_'. $version, true ); + $result = update_option('postman_release_version', true ); } + function dismiss_donation_notify() { + check_ajax_referer( 'postsmtp', 'security' ); + + $result = update_option('postman_dismiss_donation', true ); + } + function delete_lock_file() { check_ajax_referer( 'postman', 'security' ); if ( ! PostmanUtils::lockFileExists() ) { - echo __('No lock file found.', Postman::TEXT_DOMAIN ); + echo __('No lock file found.', 'post-smtp' ); die(); } - echo PostmanUtils::deleteLockFile() == true ? __('Success, try to send test email.', Postman::TEXT_DOMAIN ) : __('Failed, try again.', Postman::TEXT_DOMAIN ); + echo PostmanUtils::deleteLockFile() == true ? __('Success, try to send test email.', 'post-smtp' ) : __('Failed, try again.', 'post-smtp' ); die(); } @@ -96,8 +102,8 @@ if ( ! class_exists( 'PostmanViewController' ) ) { */ public function generateDefaultContent() { // This page will be under "Settings" - $pageTitle = sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ); - $pluginName = __( 'Post SMTP', Postman::TEXT_DOMAIN ); + $pageTitle = sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ); + $pluginName = __( 'Post SMTP', 'post-smtp' ); $uniqueId = self::POSTMAN_MENU_SLUG; $pageOptions = array( $this, @@ -119,7 +125,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { * Register the Email Test screen */ public function addPurgeDataSubmenu() { - $page = add_submenu_page( null, sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ), __( 'Post SMTP', Postman::TEXT_DOMAIN ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array( + $page = add_submenu_page( null, sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ), __( 'Post SMTP', 'post-smtp' ), Postman::MANAGE_POSTMAN_CAPABILITY_NAME, PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG, array( $this, 'outputPurgeDataContent', ) ); @@ -157,15 +163,15 @@ if ( ! class_exists( 'PostmanViewController' ) ) { ), '1.13.1' ); wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_ajax_msg', array( - 'bad_response' => __( 'An unexpected error occurred', Postman::TEXT_DOMAIN ), - 'corrupt_response' => __( 'Unexpected PHP messages corrupted the Ajax response', Postman::TEXT_DOMAIN ), + 'bad_response' => __( 'An unexpected error occurred', 'post-smtp' ), + 'corrupt_response' => __( 'Unexpected PHP messages corrupted the Ajax response', 'post-smtp' ), ) ); wp_localize_script( 'jquery_steps_script', 'steps_current_step', 'steps_current_step' ); wp_localize_script( 'jquery_steps_script', 'steps_pagination', 'steps_pagination' ); - wp_localize_script( 'jquery_steps_script', 'steps_finish', _x( 'Finish', 'Press this button to Finish this task', Postman::TEXT_DOMAIN ) ); - wp_localize_script( 'jquery_steps_script', 'steps_next', _x( 'Next', 'Press this button to go to the next step', Postman::TEXT_DOMAIN ) ); - wp_localize_script( 'jquery_steps_script', 'steps_previous', _x( 'Previous', 'Press this button to go to the previous step', Postman::TEXT_DOMAIN ) ); + wp_localize_script( 'jquery_steps_script', 'steps_finish', _x( 'Finish', 'Press this button to Finish this task', 'post-smtp' ) ); + wp_localize_script( 'jquery_steps_script', 'steps_next', _x( 'Next', 'Press this button to go to the next step', 'post-smtp' ) ); + wp_localize_script( 'jquery_steps_script', 'steps_previous', _x( 'Previous', 'Press this button to go to the previous step', 'post-smtp' ) ); wp_localize_script( 'jquery_steps_script', 'steps_loading', 'steps_loading' ); } @@ -177,7 +183,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { print '<div class="wrap">'; $this->displayTopNavigation(); if ( ! PostmanPreRequisitesCheck::isReady() ) { - printf( '<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', __( 'Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).', Postman::TEXT_DOMAIN ) ); + printf( '<p><span style="color:red; padding:2px 0; font-size:1.1em">%s</span></p>', __( 'Postman is unable to run. Email delivery is being handled by WordPress (or another plugin).', 'post-smtp' ) ); } else { $ready_messsage = PostmanTransportRegistry::getInstance()->getReadyMessage(); $statusMessage = $ready_messsage['message']; @@ -193,27 +199,32 @@ if ( ! class_exists( 'PostmanViewController' ) ) { $this->printDeliveryDetails(); /* translators: where %d is the number of emails delivered */ print '<p style="margin:10px 10px"><span>'; - printf( _n( 'Postman has delivered <span style="color:green">%d</span> email.', 'Postman has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance()->getSuccessfulDeliveries(), Postman::TEXT_DOMAIN ), PostmanState::getInstance()->getSuccessfulDeliveries() ); + printf( _n( 'Postman has delivered <span style="color:green">%d</span> email.', 'Postman has delivered <span style="color:green">%d</span> emails.', PostmanState::getInstance()->getSuccessfulDeliveries(), 'post-smtp' ), PostmanState::getInstance()->getSuccessfulDeliveries() ); if ( $this->options->isMailLoggingEnabled() ) { print ' '; - printf( __( 'The last %d email attempts are recorded <a href="%s">in the log</a>.', Postman::TEXT_DOMAIN ), PostmanOptions::getInstance()->getMailLoggingMaxEntries(), PostmanUtils::getEmailLogPageUrl() ); + printf( __( 'The last %d email attempts are recorded <a href="%s">in the log</a>.', 'post-smtp' ), PostmanOptions::getInstance()->getMailLoggingMaxEntries(), PostmanUtils::getEmailLogPageUrl() ); } print '</span></p>'; } if ( $this->options->isNew() ) { - printf( '<h3 style="padding-top:10px">%s</h3>', __( 'Thank-you for choosing Postman!', Postman::TEXT_DOMAIN ) ); + printf( '<h3 style="padding-top:10px">%s</h3>', __( 'Thank-you for choosing Postman!', 'post-smtp' ) ); /* translators: where %s is the URL of the Setup Wizard */ - printf( '<p><span>%s</span></p>', sprintf( __( 'Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.', Postman::TEXT_DOMAIN ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ) ) ); - printf( '<p><span>%s</span></p>', sprintf( __( 'Alternately, <a href="%s">manually configure</a> your own settings and/or modify advanced options.', Postman::TEXT_DOMAIN ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ) ) ); + printf( '<p><span>%s</span></p>', sprintf( __( 'Let\'s get started! All users are strongly encouraged to <a href="%s">run the Setup Wizard</a>.', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ) ) ); + printf( '<p><span>%s</span></p>', sprintf( __( 'Alternately, <a href="%s">manually configure</a> your own settings and/or modify advanced options.', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ) ) ); } else { if ( PostmanState::getInstance()->isTimeToReviewPostman() && ! PostmanOptions::getInstance()->isNew() ) { print '</br><hr width="70%"></br>'; /* translators: where %s is the URL to the WordPress.org review and ratings page */ - printf( '%s</span></p>', sprintf( __( 'Please consider <a href="%s">leaving a review</a> to help spread the word! :D', Postman::TEXT_DOMAIN ), 'https://wordpress.org/support/view/plugin-reviews/post-smtp?filter=5' ) ); + printf( '%s</span></p>', sprintf( __( 'Please consider <a href="%s">leaving a review</a> to help spread the word! :D', 'post-smtp' ), 'https://wordpress.org/support/view/plugin-reviews/post-smtp?filter=5' ) ); } - printf( '<p><span>%s :-)</span></p>', sprintf( __( 'Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>', Postman::TEXT_DOMAIN ), 'https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable' ) ); + printf( '<p><span>%s :-)</span></p>', sprintf( __( 'Postman needs translators! Please take a moment to <a href="%s">translate a few sentences on-line</a>', 'post-smtp' ), 'https://translate.wordpress.org/projects/wp-plugins/post-smtp/stable' ) ); } - printf( '<p><span>%s</span></p>', __( '<b style="background-color:yellow">New for v1.7!</style></b> Send mail with the Mandrill or SendGrid APIs.', Postman::TEXT_DOMAIN ) ); + printf( + '<p><span>%s</span> <a target="_blank" href="%s">%s</a></p>', + __( '<b style="background-color:yellow">New for v1.9.8!</b> Fallback - setup a second delivery method when the first one is failing', 'post-smtp' ), + 'https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/', + __( 'Check the detailes here', 'post-smtp') + ); } /** @@ -226,33 +237,33 @@ if ( ! class_exists( 'PostmanViewController' ) ) { /** * - * @param unknown $title + * @param mixed $title * @param string $slug */ public static function outputChildPageHeader( $title, $slug = '' ) { - printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) ); + printf( '<h2>%s</h2>', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) ); printf( '<div id="postman-main-menu" class="welcome-panel %s">', $slug ); print '<div class="welcome-panel-content">'; print '<div class="welcome-panel-column-container">'; print '<div class="welcome-panel-column welcome-panel-last">'; printf( '<h4>%s</h4>', $title ); print '</div>'; - printf( '<p id="back_to_main_menu">%s <a id="back_to_menu_link" href="%s">%s</a></p>', self::BACK_ARROW_SYMBOL, PostmanUtils::getSettingsPageUrl(), _x( 'Back To Main Menu', 'Return to main menu link', Postman::TEXT_DOMAIN ) ); + printf( '<p id="back_to_main_menu">%s <a id="back_to_menu_link" href="%s">%s</a></p>', self::BACK_ARROW_SYMBOL, PostmanUtils::getSettingsPageUrl(), _x( 'Back To Main Menu', 'Return to main menu link', 'post-smtp' ) ); print '</div></div></div>'; } /** */ public function outputPurgeDataContent() { - $importTitle = __( 'Import', Postman::TEXT_DOMAIN ); - $exportTile = __( 'Export', Postman::TEXT_DOMAIN ); - $resetTitle = __( 'Reset Plugin', Postman::TEXT_DOMAIN ); + $importTitle = __( 'Import', 'post-smtp' ); + $exportTile = __( 'Export', 'post-smtp' ); + $resetTitle = __( 'Reset Plugin', 'post-smtp' ); $options = $this->options; print '<div class="wrap">'; PostmanViewController::outputChildPageHeader( sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ) ); print '<section id="export_settings">'; printf( '<h3><span>%s<span></h3>', $exportTile ); - printf( '<p><span>%s</span></p>', __( 'Copy this data into another instance of Postman to duplicate the configuration.', Postman::TEXT_DOMAIN ) ); + printf( '<p><span>%s</span></p>', __( 'Copy this data into another instance of Postman to duplicate the configuration.', 'post-smtp' ) ); $data = ''; if ( ! PostmanPreRequisitesCheck::checkZlibEncode() ) { $extraDeleteButtonAttributes = sprintf( 'disabled="true"' ); @@ -271,15 +282,15 @@ if ( ! class_exists( 'PostmanViewController' ) ) { wp_nonce_field( PostmanAdminController::IMPORT_SETTINGS_SLUG ); printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::IMPORT_SETTINGS_SLUG ); print '<p>'; - printf( '<span>%s</span>', __( 'Paste data from another instance of Postman here to duplicate the configuration.', Postman::TEXT_DOMAIN ) ); + printf( '<span>%s</span>', __( 'Paste data from another instance of Postman here to duplicate the configuration.', 'post-smtp' ) ); if ( PostmanTransportRegistry::getInstance()->getSelectedTransport()->isOAuthUsed( PostmanOptions::getInstance()->getAuthenticationType() ) ) { - $warning = __( 'Warning', Postman::TEXT_DOMAIN ); - $errorMessage = __( 'Using the same OAuth 2.0 Client ID and Client Secret from this site at the same time as another site will cause failures.', Postman::TEXT_DOMAIN ); + $warning = __( 'Warning', 'post-smtp' ); + $errorMessage = __( 'Using the same OAuth 2.0 Client ID and Client Secret from this site at the same time as another site will cause failures.', 'post-smtp' ); printf( ' <span><b>%s</b>: %s</span>', $warning, $errorMessage ); } print '</p>'; printf( '<textarea cols="80" rows="5" name="settings" %s></textarea>', $extraDeleteButtonAttributes ); - submit_button( __( 'Import', Postman::TEXT_DOMAIN ), 'primary', 'import', true, $extraDeleteButtonAttributes ); + submit_button( __( 'Import', 'post-smtp' ), 'primary', 'import', true, $extraDeleteButtonAttributes ); print '</form>'; print '</section>'; print '<section id="delete_settings">'; @@ -287,7 +298,7 @@ if ( ! class_exists( 'PostmanViewController' ) ) { print '<form method="POST" action="' . get_admin_url() . 'admin-post.php">'; wp_nonce_field( PostmanAdminController::PURGE_DATA_SLUG ); printf( '<input type="hidden" name="action" value="%s" />', PostmanAdminController::PURGE_DATA_SLUG ); - printf( '<p><span>%s</span></p><p><span>%s</span></p>', __( 'This will purge all of Postman\'s settings, including account credentials and the email log.', Postman::TEXT_DOMAIN ), __( 'Are you sure?', Postman::TEXT_DOMAIN ) ); + printf( '<p><span>%s</span></p><p><span>%s</span></p>', __( 'This will purge all of Postman\'s settings, including account credentials and the email log.', 'post-smtp' ), __( 'Are you sure?', 'post-smtp' ) ); $extraDeleteButtonAttributes = 'style="background-color:red;color:white"'; if ( $this->options->isNew() ) { $extraDeleteButtonAttributes .= ' disabled="true"'; @@ -302,14 +313,14 @@ if ( ! class_exists( 'PostmanViewController' ) ) { */ private function displayTopNavigation() { $version = PostmanState::getInstance()->getVersion(); - $show = get_option('postman_release_version_'. $version ); - printf( '<h2>%s</h2>', sprintf( __( '%s Setup', Postman::TEXT_DOMAIN ), __( 'Post SMTP', Postman::TEXT_DOMAIN ) ) ); + $show = get_option('postman_release_version' ); + printf( '<h2>%s</h2>', sprintf( __( '%s Setup', 'post-smtp' ), __( 'Post SMTP', 'post-smtp' ) ) ); if ( ! $show ) { echo ' <div class="updated settings-error notice is-dismissible"> <p> - <strong>Version ' . $version . ' The SMTP Fallback ( A backup delivery SMTP ):</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-1-9-7-the-smtp-fallback/">Read Here</a> + <strong>Version ' . $version . ' Mailer Type:</strong> <a target="_blank" href="https://postmansmtp.com/post-smtp-2-0-mailer-type-and-much-more/">Read Here</a> </p> <button style="z-index: 100;" data-version="'. $version . '" data-security="' . wp_create_nonce('postsmtp') .'" type="button" class="notice-dismiss postman-release-message"> <span class="screen-reader-text">Dismiss this notice.</span> @@ -317,49 +328,58 @@ if ( ! class_exists( 'PostmanViewController' ) ) { </div>'; } - print '<div id="postman-main-menu" class="welcome-panel">'; - print '<div class="welcome-panel-content">'; - print '<div class="welcome-panel-column-container">'; - print '<div class="welcome-panel-column">'; - printf( '<h4>%s</h4>', __( 'Configuration', Postman::TEXT_DOMAIN ) ); - printf( '<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', Postman::TEXT_DOMAIN ) ); - printf( '<p class="">%s <a href="%s" class="configure_manually">%s</a></p>', __( 'or', Postman::TEXT_DOMAIN ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', Postman::TEXT_DOMAIN ) ); - print '</div>'; - print '<div class="welcome-panel-column">'; - printf( '<h4>%s</h4>', _x( 'Actions', 'Main Menu', Postman::TEXT_DOMAIN ) ); - print '<ul>'; - - // Grant permission with Google - PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); - - if ( PostmanWpMailBinder::getInstance()->isBound() ) { - printf( '<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', Postman::TEXT_DOMAIN ) ); - } else { - printf( '<li><div class="welcome-icon send_test_email">%s</div></li>', __( 'Send a Test Email', Postman::TEXT_DOMAIN ) ); - } - - // import-export-reset menu item - if ( ! $this->options->isNew() || true ) { - $purgeLinkPattern = '<li><a href="%1$s" class="welcome-icon oauth-authorize">%2$s</a></li>'; - } else { - $purgeLinkPattern = '<li>%2$s</li>'; - } - $importTitle = __( 'Import', Postman::TEXT_DOMAIN ); - $exportTile = __( 'Export', Postman::TEXT_DOMAIN ); - $resetTitle = __( 'Reset Plugin', Postman::TEXT_DOMAIN ); - $importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ); - printf( $purgeLinkPattern, $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ), sprintf( '%s', $importExportReset ) ); - print '</ul>'; - print '</div>'; - print '<div class="welcome-panel-column welcome-panel-last">'; - printf( '<h4>%s</h4>', _x( 'Troubleshooting', 'Main Menu', Postman::TEXT_DOMAIN ) ); - print '<ul>'; - printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', Postman::TEXT_DOMAIN ) ); - printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', Postman::TEXT_DOMAIN ) ); - printf( '<li><a href="%s" data-security="%s" class="welcome-icon release-lock-file">%s</a></li>', '#', wp_create_nonce( "postman" ), __( 'Release Lock File Error', Postman::TEXT_DOMAIN ) ); - printf( '<li><a href="https://postmansmtp.com/forums/" class="welcome-icon postman_support">%s</a></li>', __( 'Online Support', Postman::TEXT_DOMAIN ) ); - printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a target="blank" class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', Postman::TEXT_DOMAIN ) ); - print '</ul></div></div></div></div>'; + include_once POST_PATH . '/Postman/extra/donation.php'; + + echo '<div class="twitter-wrap">'; + print '<div id="postman-main-menu" class="welcome-panel">'; + print '<div class="welcome-panel-content">'; + print '<div class="welcome-panel-column-container">'; + print '<div class="welcome-panel-column">'; + printf( '<h4>%s</h4>', __( 'Configuration', 'post-smtp' ) ); + printf( '<a class="button button-primary button-hero" href="%s">%s</a>', $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_WIZARD_SLUG ), __( 'Start the Wizard', 'post-smtp' ) ); + printf( '<p class="">%s <a href="%s" class="configure_manually">%s</a></p>', __( 'or', 'post-smtp' ), $this->getPageUrl( PostmanConfigurationController::CONFIGURATION_SLUG ), __( 'Show All Settings', 'post-smtp' ) ); + print '</div>'; + print '<div class="welcome-panel-column">'; + printf( '<h4>%s</h4>', _x( 'Actions', 'Main Menu', 'post-smtp' ) ); + print '<ul>'; + + // Grant permission with Google + PostmanTransportRegistry::getInstance()->getSelectedTransport()->printActionMenuItem(); + + if ( PostmanWpMailBinder::getInstance()->isBound() ) { + printf( '<li><a href="%s" class="welcome-icon send_test_email">%s</a></li>', $this->getPageUrl( PostmanSendTestEmailController::EMAIL_TEST_SLUG ), __( 'Send a Test Email', 'post-smtp' ) ); + } else { + printf( '<li><div class="welcome-icon send_test_email">%s</div></li>', __( 'Send a Test Email', 'post-smtp' ) ); + } + + // import-export-reset menu item + if ( ! $this->options->isNew() || true ) { + $purgeLinkPattern = '<li><a href="%1$s" class="welcome-icon oauth-authorize">%2$s</a></li>'; + } else { + $purgeLinkPattern = '<li>%2$s</li>'; + } + $importTitle = __( 'Import', 'post-smtp' ); + $exportTile = __( 'Export', 'post-smtp' ); + $resetTitle = __( 'Reset Plugin', 'post-smtp' ); + $importExportReset = sprintf( '%s/%s/%s', $importTitle, $exportTile, $resetTitle ); + printf( $purgeLinkPattern, $this->getPageUrl( PostmanAdminController::MANAGE_OPTIONS_PAGE_SLUG ), sprintf( '%s', $importExportReset ) ); + print '</ul>'; + print '</div>'; + print '<div class="welcome-panel-column welcome-panel-last">'; + printf( '<h4>%s</h4>', _x( 'Troubleshooting', 'Main Menu', 'post-smtp' ) ); + print '<ul>'; + printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ), __( 'Connectivity Test', 'post-smtp' ) ); + printf( '<li><a href="%s" class="welcome-icon run-port-test">%s</a></li>', $this->getPageUrl( PostmanDiagnosticTestController::DIAGNOSTICS_SLUG ), __( 'Diagnostic Test', 'post-smtp' ) ); + printf( '<li><a href="%s" data-security="%s" class="welcome-icon release-lock-file">%s</a></li>', '#', wp_create_nonce( "postman" ), __( 'Release Lock File Error', 'post-smtp' ) ); + printf( '<li><a href="https://postmansmtp.com/forums/" class="welcome-icon postman_support">%s</a></li>', __( 'Online Support', 'post-smtp' ) ); + printf( '<li><img class="align-middle" src="' . plugins_url( 'style/images/new.gif', dirname( __DIR__ ) . '/postman-smtp.php' ) . '"><a target="blank" class="align-middle" href="https://postmansmtp.com/category/guides/" class="welcome-icon postman_guides">%s</a></li>', __( 'Guides', 'post-smtp' ) ); + print '</ul></div></div></div></div>'; + ?> + <div class="twitter-iframe-wrap" style="min-width: 300px;"> + <a class="twitter-timeline" data-height="304" href="https://twitter.com/PostSMTP?ref_src=twsrc%5Etfw">Tweets by PostSMTP</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> + </div> + </div> + <?php } } } diff --git a/Postman/PostmanWpMail.php b/Postman/PostmanWpMail.php index 173b35e..66b3279 100644 --- a/Postman/PostmanWpMail.php +++ b/Postman/PostmanWpMail.php @@ -1,4 +1,5 @@ <?php + if ( ! class_exists( 'PostmanWpMail' ) ) { /** @@ -29,11 +30,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { * Exceptions are held for later inspection. * An instance of PostmanState updates the success/fail tally. * - * @param unknown $to - * @param unknown $subject - * @param unknown $body - * @param unknown $headers - * @param unknown $attachments + * @param mixed $to + * @param mixed $subject + * @param mixed $body + * @param mixed $headers + * @param mixed $attachments * @return boolean */ public function send( $to, $subject, $message, $headers = '', $attachments = array() ) { @@ -55,14 +56,41 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { return $this->sendMessage( $postmanMessage, $log ); } + /** + * @param PostmanMessage $message + * @return PostmanMessage + */ + private function apply_default_headers( $message ) { + $headers[] = 'Message-ID: ' . $this->createMessageId(); + $message->addHeaders($headers); + } + + /** + * Creates the Message-ID + * + * @return string + */ + public function createMessageId() { + + $id = md5(uniqid(time())); + + if (isset($_SERVER["SERVER_NAME"])) { + $hostName = $_SERVER["SERVER_NAME"]; + } else { + $hostName = php_uname('n'); + } + + return $id . '@' . $hostName; + } + /** * Builds a PostmanMessage based on the WordPress wp_mail parameters * - * @param unknown $to - * @param unknown $subject - * @param unknown $message - * @param unknown $headers - * @param unknown $attachments + * @param mixed $to + * @param mixed $subject + * @param mixed $message + * @param mixed $headers + * @param mixed $attachments */ private function processWpMailCall( $to, $subject, $message, $headers, $attachments ) { $this->logger->trace( 'wp_mail parameters before applying WordPress wp_mail filter:' ); @@ -147,6 +175,8 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { */ public function sendMessage( PostmanMessage $message, PostmanEmailLog $log ) { + $this->apply_default_headers( $message ); + // get the Options and AuthToken $options = PostmanOptions::getInstance(); $authorizationToken = PostmanOAuthToken::getInstance(); @@ -254,6 +284,9 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) ); // return failure + if ( PostmanOptions::getInstance()->getSmtpMailer() == 'phpmailer' ) { + throw new phpmailerException($e->getMessage(), $e->getCode()); + } return false; } @@ -282,7 +315,7 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { * Clean up after sending the mail * * @param PostmanZendMailEngine $engine - * @param unknown $startTime + * @param mixed $startTime */ private function postSend( PostmanMailEngine $engine, $startTime, PostmanOptions $options, PostmanModuleTransport $transport ) { // save the transcript @@ -338,11 +371,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { /** * Aggregates all the content into a Message to be sent to the MailEngine * - * @param unknown $to - * @param unknown $subject - * @param unknown $body - * @param unknown $headers - * @param unknown $attachments + * @param mixed $to + * @param mixed $subject + * @param mixed $body + * @param mixed $headers + * @param mixed $attachments */ private function populateMessageFromWpMailParams( PostmanMessage $message, $to, $subject, $body, $headers, $attachments ) { $message->addHeaders( $headers ); @@ -356,11 +389,11 @@ if ( ! class_exists( 'PostmanWpMail' ) ) { /** * Trace the parameters to aid in debugging * - * @param unknown $to - * @param unknown $subject - * @param unknown $body - * @param unknown $headers - * @param unknown $attachments + * @param mixed $to + * @param mixed $subject + * @param mixed $body + * @param mixed $headers + * @param mixed $attachments */ private function traceParameters( $to, $subject, $message, $headers, $attachments ) { $this->logger->trace( 'to:' ); diff --git a/Postman/PostmanWpMailBinder.php b/Postman/PostmanWpMailBinder.php index b0be8f4..95eb898 100644 --- a/Postman/PostmanWpMailBinder.php +++ b/Postman/PostmanWpMailBinder.php @@ -2,7 +2,7 @@ if (! class_exists ( 'PostmanWpMailBinder' )) { class PostmanWpMailBinder { private $logger; - private $bound; + public $bound; private $bindError; /** @@ -26,7 +26,7 @@ if (! class_exists ( 'PostmanWpMailBinder' )) { /** * Return the Singleton instance * - * @return Ambigous <NULL, PostmanWpMailBinder> + * @return PostmanWpMailBinder */ public static function getInstance() { static $inst = null; @@ -90,8 +90,6 @@ if (! class_exists ( 'PostmanWpMailBinder' )) { * * If the function does not exist, then the replacement was successful * and we set a success flag. - * - * @return boolean */ private function replacePluggableFunctionWpMail() { /** diff --git a/Postman/extra/donation.php b/Postman/extra/donation.php new file mode 100644 index 0000000..61fc3a9 --- /dev/null +++ b/Postman/extra/donation.php @@ -0,0 +1,19 @@ +<?php +$postman_dismiss_donation = get_option('postman_dismiss_donation'); + +if ( empty( $postman_dismiss_donation ) || isset( $in_wizard ) ) : ?> + <div class="updated settings-error notice is-dismissible post-smtp-donation"> + <p style="font-size: 1.1em;">It is hard to continue development and support for this free plugin without contributions from users like you.<br> + If you enjoy using <strong>Post SMTP</strong> and find it useful, please consider making a donation.<br> + Your donation will help encourage and support the plugin's continued development and better user support.</p> + <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> + <input type="hidden" name="cmd" value="_s-xclick" /> + <input type="hidden" name="hosted_button_id" value="4B3PJANHBA7MG" /> + <input type="image" src="https://www.paypalobjects.com/en_US/IL/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" /> + <img alt="" border="0" src="https://www.paypal.com/en_IL/i/scr/pixel.gif" width="1" height="1" /> + </form> + <button style="z-index: 100;" data-security="<?php echo wp_create_nonce('postsmtp'); ?>" type="button" class="notice-dismiss donation-dismiss"> + <span class="screen-reader-text">Dismiss this notice.</span> + </button> + </div> +<?php endif; ?>
\ No newline at end of file diff --git a/Postman/notifications/PostmanMailNotify.php b/Postman/notifications/PostmanMailNotify.php index 0313f7f..a76fb2a 100644 --- a/Postman/notifications/PostmanMailNotify.php +++ b/Postman/notifications/PostmanMailNotify.php @@ -7,6 +7,6 @@ class PostmanMailNotify implements Postman_Notify { $to_email = apply_filters( 'post_smtp_notify_email',get_bloginfo( 'admin_email' ) ); $domain = get_bloginfo( 'url' ); - mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', Postman::TEXT_DOMAIN ), $message , '', "-f{$to_email}" ); + mail( $to_email, "{$domain}: " . __( 'Post SMTP email error', 'post-smtp' ), $message , '', "-f{$to_email}" ); } }
\ No newline at end of file |