rdelbem/wp-mailer-class
最新稳定版本:1.0.2
Composer 安装命令:
composer require rdelbem/wp-mailer-class
包简介
Just a simple wrapper around the wp_mail function, now you can easily send an email from within WP without having to set a header by youself. We also provide some error handling
README 文档
README
The intention of this snippet is to facilitate the use of wp_mail native function. Normally, when using, wp_mail, some parameters are required in order for it to work: headers, subject, body etc.
If all you have is the user id, you will need to use other WordPress function to get the email and, only then, pass it to wp_mail. While, coding a plugin or a theme, this will require a different file and class, as calling all this wp functions will, most certanly, make a mess in your code.
However, if you use WPMailerClass, you only need to provide ONE relevant receiver data, id OR email. See the examples:
Here, only id is provided
$send_mail = new WPMailerClass( 1, 'Amazing subject!', 'Amazing message!' ); $send_mail->sendEmail();
Here, only e-mail is provided
$send_mail = new WPMailerClass( 'youruser@mail.com', 'Amazing subject!', 'Amazing message!' ); $send_mail->sendEmail();
And if you want to defensive handle errors you can do the following
$send_mail = new WPMailerClass( 'youruser@mail.com', 'Amazing subject!', 'Amazing message!' ); $result = $send_mail->sendEmail(); if($result instanceof WP_Error){ error_log($result->get_error_message()); // this will log 'WPMailerClass could not send email' }
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2023-01-29