阿里云的邮件推送,还是很好用的,每天200封免费。非常稳定,有详细的发送日志可以查看。
这里使用基于阿里云提供的php sdk来编写发邮件代码。
php sdk下载地址:https://help.aliyun.com/document_detail/29460.html
使用方法如下:
public static function send_mail_aliyun($address_mail, $subject, $body, $tag="") { //这里引用config.php require_once "aliyun-php-sdk-core/config.php"; $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", ACCESSKEY, KEYSECRET); $client = new DefaultAcsClient($iClientProfile); $request = new Dm\Request\V20151123\SingleSendMailRequest(); $request->setAccountName(DOMAIN); $request->setFromAlias(ALIAS); $request->setAddressType(1); if($tag){ $request->setTagName($tag); } $request->setReplyToAddress("false"); $request->setToAddress($address_mail); $request->setSubject($subject); $request->setHtmlBody($body); try { $response = $client->getAcsResponse($request); // print_r($response); } catch (ClientException $e) { // print_r($e->getErrorCode()); // print_r($e->getErrorMessage()); } catch (ServerException $e) { // print_r($e->getErrorCode()); // print_r($e->getErrorMessage()); } }
修改几处参数即可,ACCESSKEY、KEYSECRET、DOMAIN、ALIAS。
阿里云后台提供了很直观的数据统计功能: