开发者 | SendGrid |
---|---|
更新时间 | 2021年3月5日 06:25 |
捐献地址: | 去捐款 |
PHP版本: | 4.6 及以上 |
WordPress版本: | 4.9 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
Yes. You can find it here
Plugin versions 1.11.x were tested and confirmed to work on PHP 5.4, 5.5, 5.6, 7.0, 7.1. It DOES NOT work on PHP 5.3 and earlier. Plugin versions 1.10.x were tested and confirmed to work on PHP 5.3, 5.4, 5.5 and 5.6. It DOES NOT work on PHP 7.0 and later.
Create a SendGrid account at https://sendgrid.com/ and generate a new API key on https://app.sendgrid.com/settings/api_keys.
Add it into your wp-config.php file. Example: define('SENDGRID_API_KEY', 'your_api_key');
.
If you have WP Better Emails plugin installed and you want to use the template defined here instead of the SendGrid template you can add the following code in your functions.php file from your theme: `function use_wpbe_template( $message, $content_type ) { global $wp_better_emails; if ( 'text/plain' == $content_type ) { $message = $wp_better_emails->process_email_text( $message ); } else { $message = $wp_better_emails->process_email_html( $message ); } return $message; } add_filter( 'sendgrid_override_template', 'use_wpbe_template', 10, 2 );` Using the default templates from WP Better Emails will cause all emails to be sent as HTML (i.e. text/html content-type). In order to send emails as plain text (i.e. text/plain content-type) you should remove the HTML Template from WP Better Emails settings page. This is can be done by removing the '%content%' tag from the HTML template.
For a detailed explanation see this page: https://sendgrid.com/docs/Classroom/Build/Format_Content/plain_text_emails_converted_to_html.html
The contacts will only be uploaded to Marketing Campaigns.
For the API Key used for sending emails (the General tab):
No. SendGrid’s Email Policy requires all email addressing being sent to by SendGrid customers be confirmed opt-in addresses.
Yes. You must add a filter that does that. You need to declare a function that takes the content of the email as argument and then call add_filter() with the name "sendgrid_mail_text" or "sendgrid_mail_html", depending on what part of the email you want to change. If you want to change the text content of all the emails before they are sent you can do it like this : `function change_sendgrid_text_email( $message ) { return $message . ' changed by way of text filter '; } add_filter( 'sendgrid_mail_text', 'change_sendgrid_text_email' );` If you want to change HTML content of all the emails before they are sent you can do it like this : `function change_sendgrid_html_email( $message ) { return $message . ' changed by way of html filter '; } add_filter( 'sendgrid_mail_html', 'change_sendgrid_html_email' );` Note that what is changed depends of the content-type that you have set in the settings page or overwritten by way of filter. For "text/plain" only the text part is overwritten by the filter. For "text/html" both the text and the HTML filters are called. The code snippets above are usually added in the functions.php file of your theme.
Yes. Our plugin required special integration with BuddyPress and it's regularly tested to ensure it behaves as expected. If you have noticed issues caused by installing this plugin along with BuddyPress, you can add the following line to your wp-config.php to disable it :
define('SENDGRID_DISABLE_BUDDYPRESS', '1');
If you're trying to send plaintext emails using BuddyPress, keep in mind that by default the whitespace content of those emails is normalized.
That means that some newlines might be missing if you expect them to be there.
To disable this functionality, you need to add the following line in your wp-config.php file:
define('SENDGRID_DISABLE_BP_NORMALIZE_WHITESPACE', '1');
Yes. You need to create custom page and select it from the settings page. You can place any of these shortcodes in the body of that page. Here's an example :
Hi [sendgridSubscriptionFirstName] [sendgridSubscriptionLastName], Your email address : [sendgridSubscriptionEmail] has been successfully added. You'll hear from us soon!
You need to enable the use of the First Name and Last Name fields from the settings page in order to use the shortcodes for them.
Yes. This plugin has basic Multisite support. You need to Network Activate this plugin. The settings for all sites in the network can be configured only by the Network Admin in the Network Admin Dashboard. Since 1.10.5 the Network Admin can delegate the configuration for each subsite to their respective owners. This will allow any subsite to use it's own SendGrid Plugin configuration.
When calling the wp_mail() function you can send a SendGrid PHP email object in the headers argument. Here is an example: `$email = new SendGrid\Email(); $email ->setFrom('me@bar.com') ->setHtml('Hello World!') ->addCategory('customCategory') ; wp_mail('foo@bar.com', 'Subject goes here', 'Message goes here', $email); ` You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v4.0.2/README.md
Yes. You can define a constant in your wp-config.php file like this:
define('SENDGRID_REQUEST_TIMEOUT', 10);
The value is in seconds, this means that API requests will wait 10 seconds for a reponse from the SendGrid API server until timing out.