【发布时间】:2021-02-19 01:59:24
【问题描述】:
所有知道如何使用输入字段获取消息和添加地址的人都好。
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>
【问题讨论】:
-
你试过
$_POST['email'];或$this->input->post('some_data')吗? -
您编写的这个脚本属于一种称为垃圾邮件网关的类型。它允许任何人向他们喜欢的任何人发送任意消息,声称来自您。这是一件非常糟糕的事情,并且可能会导致您的服务器被阻止。如果您想制作联系表格,请查看 PHPMailer 提供的示例,该示例不会遇到这些问题。
-
是的,先生,我会检查你的 repo github 以获取示例联系表。
标签: codeigniter phpmailer