在用户使用PhpMailer批准后,如何向用户发送电子邮件

时间:2019-01-30 12:15:59

标签: php codeigniter phpmailer

我有一个表,显示已注册用户的记录(正在等待批准)。因此,我创建了一个功能,可以批准他们的会员资格,同时向他们发送电子邮件(通过表格上显示的电子邮件)。但是,在用户成功更新数据库后,他们不会收到电子邮件通知。 这就是我从数据库中获取记录的方式:

                <?php echo form_open('controls/view'); ?>
                              <table class="table table-bordered">
                                <tr class="table table-dark">
                                    <th class="table-active"><b>Name</b></th>
                                    <th class="table-active"><b>Email</b></th>
                                    <th class="table-active"><b>Company</b></th>
                                    <th class="table-active"><b>Mobile Number</b></th>
                                    <th class="table-active"><b>Mpesa Code</b></th>
                                    <th class="table-active"><b>Action</b></th>
                                </tr>
                                <?php foreach ($snm_users as $user): ?>
                                    <tr>
                                         <td><input type="text" name="fname" value="<?php echo $user['fname']; ?>"></td>
                                         <td><input type="email" name="email" value="<?php echo $user['email']; ?>"></td>
                                         <td><input type="text" name="company" value="<?php echo $user['company']; ?>"></td>
                                         <td><input type="text" name="mobile_number" value="<?php echo $user['mobile_number']; ?>"></td>
                                         <td><input type="text" name="mpesa" value="<?php echo $user['mpesa']; ?>"></td>
                                         <td><a href="#" class="btn-success" id="<?php echo $user['user_id']; ?>">Approve</a> </td>
                                    </tr>
                                <?php endforeach; ?>
                                </table>
                            <?php echo form_close(); ?>

我正在使用PHPMailer发送电子邮件,这是我配置发送电子邮件的位置:

            // SMTP configuration
            $mail->isSMTP();
            $mail->Host     = 'smtp.gmail.com';
            $mail->SMTPAuth = true;
            $mail->Username = 'kibete20@gmail.com';
            $mail->Password = '*******';
            $mail->SMTPSecure = 'ssl';
            $mail->Port     = 465;

            $mail->setFrom($this->input->post('email'), 'My Hub');

            // Add a recipient
            $mail->addAddress($this->input->post('email'));
            // Add cc or bcc

            // Email subject
            $mail->Subject = 'Application for Ehub Membership';

            // Set email format to HTML
            $mail->isHTML(true);

0 个答案:

没有答案