我创建了这个电子邮件发送表单,它一直有效,直到我将代码更改为此(这是我的控制器):
public function sendMail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'mymail@gmail.com',
'smtp_pass' => 'mypass',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($this->input->post('email'));
$this->email->to('mymail@gmail.com');
$this->email->phone($this->input->post('phone'));
$this->email->contact($this->input->post('contact'));
$this->email->subject($this->input->post('subject'));
$this->email->message($this->input->post('message'));
if( $this->email->send() ){
redirect ('/');
} else
{
show_error($this->email->print_debugger());
}
}
和HTML / PHP部分:
<form method="post" action="<?php echo base_url('Email/sendMail'); ?>" accept-charset="utf-8" name="contactform" id="contactform">
<div class="col-md-6">
<fieldset>
<input name="first_name" type="text" id="name" size="30" placeholder="Név">
<br>
<input name="contact" type="text" id="contact" size="30" placeholder="Email">
<br>
<input name="phone" type="text" id="phone" size="30" placeholder="Telefon">
<br>
<input name="subject" type="text" id="subject" size="30" placeholder="Tárgy">
<br>
</fieldset>
</div>
<div class="col-md-6">
<fieldset>
<textarea name="message" cols="40" rows="20" id="message" placeholder="Üzenet, Kérdés, Kérés..."></textarea>
</fieldset>
</div>
<div class="col-md-12">
<fieldset>
<input type="submit" class="btn btn-lg" name="submit" id="submit" value="Üzenet Elküldése">
</div>
</form>
提交后,张贴一个: 消息:调用未定义的方法CI_Email :: contact() 也在电话等。
提前感谢您的帮助!
答案 0 :(得分:0)
电子邮件库中没有联系人/电话方式。应该是你的信息的一部分,所以你需要做这样的事情:
$this->email->message($this->input->post("message") .
"<br><b>Phone:</b> " . $this->input->post("phone") .
"<b><b>Contact:</b>" . $this->input->post("contact"));