所以,我使用Wordpress拍卖主题。我希望卖家在有人出价购买他们的产品时收到一封电子邮件。主题本身有一个电子邮件设置,您可以在其中设置此类邮件。但我想要这样的东西是没有选择的。
所以我有一个想法,当有人按下出价按钮时,它会自动向卖家发送已经写好的信息。
这可能吗?我尝试了许多php脚本,例如:
<form action="" method="post">
<input type="submit" value="Send details to embassy" />
<input type="hidden" name="button_pressed" value="1" />
</form>
<?php
if(isset($_POST['button_pressed']))
{
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "'r'n" .
'Reply-To: webmaster@example.com' . "'r'n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
我不想把按钮改成这样:输入类型。这是一个带有样式的简单div。这可能吗?谢谢你的帮助!
使用wp_mail函数而不是mail()来发送类似的电子邮件。。
<?php
if(isset($_POST['button_pressed']))
{
$to = 'abc@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "'r'n" .
'Reply-To: webmaster@example.com' . "'r'n" .
'X-Mailer: PHP/' . phpversion();
wp_mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
单击此处显示wp_mail 的更多详细信息