forked from humanmade/aws-ses-wp-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-ses-wp-mail.php
39 lines (33 loc) · 1.38 KB
/
aws-ses-wp-mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php // @codingStandardsIgnoreLine
/**
* Plugin Name: AWS SES wp_mail drop-in
* Plugin URI: https://github.com/humanmade/aws-ses-wp-mail
* Description: Drop-in replacement for wp_mail using the AWS SES.
* Version: 0.1.1
* Author: Joe Hoyle | Human Made
* Author URI: https://github.com/humanmade
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ( ! defined( 'AWS_SES_WP_MAIL_KEY' ) || ! defined( 'AWS_SES_WP_MAIL_SECRET' ) || ! defined( 'AWS_SES_WP_MAIL_REGION' ) ) && ! defined( 'AWS_SES_WP_MAIL_USE_INSTANCE_PROFILE' ) ) {
return;
}
require_once dirname( __FILE__ ) . '/inc/class-ses.php';
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once dirname( __FILE__ ) . '/inc/class-wp-cli-command.php';
WP_CLI::add_command( 'aws-ses', 'AWS_SES_WP_Mail\\WP_CLI_Command' );
}
if ( ! function_exists( 'wp_mail' ) ) :
function wp_mail( $to, $subject, $message, $headers = '', $attachments = [] ) { // @codingStandardsIgnoreLine
$result = AWS_SES_WP_Mail\SES::get_instance()->send_wp_mail( $to, $subject, $message, $headers, $attachments );
if ( is_wp_error( $result ) ) {
trigger_error(
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
sprintf( 'Sendmail SES Email failed: %d %s', $result->get_error_code(), $result->get_error_message() ),
E_USER_WARNING
);
return false;
}
return $result;
}
endif;