wordpress由用户驱动发送邮件

使用场景举例:用户注册、发送测试结果等

模板singe中添加代码:

<?php
if (isset($_POST['useremail'])){
$to = $_POST['useremail'];
$subject = $_POST['usertitle'];
$body = $_POST['userresult'];
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
}
?>

文章内添加代码:

<form action="" method="post" name="mymail">
请输入常用邮箱:<br />
<input name="useremail" type="text" value=""/>
<input name="usertitle" type="text" value=""/>
<input name="userresult" type="text" value=""/>
<input type="submit" value="发送邮件"/>
</form>
赞 (0) 打赏

评论 0

觉得文章有用就打赏一下吧

微信扫一扫打赏