【问题标题】:How to send an email message to seller when user press on a specific button(Wordpress Auction Theme)当用户按下特定按钮时如何向卖家发送电子邮件(Wordpress 拍卖主题)
【发布时间】:2016-04-19 11:19:30
【问题描述】:

所以,我正在使用 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。那可能吗? 感谢您的帮助!

【问题讨论】:

    标签: php wordpress email


    【解决方案1】:

    使用 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.';
    }
    ?>
    

    Click here to show more detail for wp_mail

    【讨论】:

    • 我应该把代码放在哪里?以及如何指明具体的 div ,以及如何指明发送给卖家邮箱的 enail?顺便谢谢你的帮助,这对我意义重大!
    • 这还不行,我把代码放在我的子主题的functions.php中
    • 不要把functions.php放在你的表单之前。
    • 我不能我没有 html 文件。都在php文件中
    猜你喜欢
    • 2020-04-29
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 2013-08-06
    • 2012-10-01
    • 2017-12-29
    • 2013-12-22
    • 1970-01-01
    相关资源
    最近更新 更多