首页 > 解决方案 > 创建发送电子邮件按钮

问题描述

我有一些在 kohana 框架中编写的旧代码。需要创建点击“发送”按钮后激活的“发送测试邮件”功能。不知道怎么做这个。测试电子邮件应包含来自电子邮件主题、内容字段的数据,并发送到输入的电子邮件地址。

<div class="block">
    <h3 class="orange">Email setup:</h3>
    <div class="form_row">

        <div>
            <label class="short">Email subject:</label>
            <?php echo Form::input('email_subject', $data['email_subject'], array('maxlength' => '100')) ?>
            <?php echo Html::image('img/help.gif', array('class' => 'help', 'width' => 13, 'height' => 13, 'title' => 'Some title, doesn't matter')) ?>
        </div>

        <div>
            <label class="textarea-label">Email content:</label>
            <?php echo Html::image('img/help.gif', array('class' => 'help', 'width' => 13, 'height' => 13, 'title' => 'Some title, doesn't matter')) ?>
            <?php echo Form::textarea('email_body', $data['email_body'], array('id' => 'textarea1')) ?>
        </div>

        <div>
            <label class="short">test email address field:</label>
            <?php echo Form::input('test_email', '' ,array('maxlength' => '50')) ?>
            <?php echo Html::image('img/help.gif', array('class' => 'help', 'width' => 13, 'height' => 13, 'title' => 'BCC address')) ?>
        </div>

        <div>
            <?php if(Auth::instance()->get_user()->username != 'some_user') echo Form::submit('save', 'Save') ?>
            <?php if(Auth::instance()->get_user()->username != 'some_user') echo Form::submit('send', 'Send test email') ?>
        </div>

    </div>
</div>

标签: phphtmlformskohana

解决方案


您可以使用表格

<form action="test.php" method="post">
<button name="btn_send">Send Email</button>
</form>

<?php
if (isset($_POST["btn_send"])) {
    //Sending email code
}
?>

推荐阅读