Codeigniter PHPMailer 如何使用输入字段获取地址和邮件内容?

Codeigniter PHPMailer how to get the address and mailcontent using inputfields?

祝大家知道如何使用输入字段获取消息和添加地址。

public function send()
    {
        $this->load->library('phpmailer_lib');
        try
        {
            $mail=$this->phpmailer_lib->load();
            $mail->setFrom('rayjayabejuela@gmail.com','Rayjay');
            $mail->addAddress('flutterrun@gmail.com'); // I want the input data came from the input fields of email.
 
            $mail->Subject="Subject Matter"; 
            $mailContent=''; I want the input data came from the input fields came from the message.
            $mail->Body=$mailContent;
            
            if($mail->send()){
                echo "Email has been set";
            }
        }
        catch(Exception $e){
            echo $mail->ErrorInfo;
        }
    }

这是我的浏览页面

<form action="<?php echo base_url(); ?>email/send" method="post">
   <br>
   <input type="email" name="email" class="form-control" placeholder="Enter Email" required>
   <br>
   <textarea name="message" class="form-control" placeholder="Enter message here" required></textarea>
   <br>
   <button type="submit" class="btn btn-primary">Send Message</button>
</form>

我会尽力帮助你。
您可以从 :

进行更改
$mail->addAddress('flutterrun@gmail.com'); 

对此:

$mail->addAddress($_POST['email']); 

您也可以对邮件内容/消息执行此操作。

public function send()
    {
        $this->load->library('phpmailer_lib');
        try
        {
            $email = $this->input->post('email');
            $message = $this->input->post('message');
            
            $mail=$this->phpmailer_lib->load();
            $mail->setFrom('rayjayabejuela@gmail.com','Rayjay');
            $mail->addAddress($email); // I want the input data came from the input fields of email.
 
            $mail->Subject="Subject Matter"; 
            $mailContent=$message; I want the input data came from the input fields came from the message.
            $mail->Body=$mailContent;
            
            if($mail->send()){
                echo "Email has been set";
            }
        }
        catch(Exception $e){
            echo $mail->ErrorInfo;
        }
    }