使用场景举例:用户注册、发送测试结果等
模板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 );
}
?>
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>
请输入常用邮箱:<br />
<input name="useremail" type="text" value=""/>
<input name="usertitle" type="text" value=""/>
<input name="userresult" type="text" value=""/>
<input type="submit" value="发送邮件"/>
</form>
打赏作者,期待美好
打赏鼓励作者,为网友提供更多更好的测试,也许一瓶水就够了。