我是 Codeigniter 的菜鸟,我想制作一个联系表格,我希望将其发送到我的 gmail。我提出了一个观点:
<div id="content">
<?php if (isset($mail_sent)): ?>
<b>Mail Sent</b>
<?php endif; ?>
<form action="<?php echo base_url() ?>" method="POST">
<b>Your Name :</b>
<br />
<input type="text" name="name" />
<br />
<b>Your Email Address:</b>
<br />
<input type="text" name="from" />
<br />
<b>Subject :</b>
<br />
<input type="text" name="subject" />
<br />
<b>Message :</b>
<br />
<textarea name="message" rows="10" cols="15"></textarea>
<br />
<input type="submit" name="q" value="Contact" />
</form>
</div>
我在我的联系页面中的同一控制器代码块中有邮件设置。它看起来像这样:
public function contact()
{
$this->load->view('header');
$this->load->view('owrb_contact');
$this->load->view('footer');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
// gmail specific settings here
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'keessonnema@gmail.com';
$config['smtp_pass'] = '123keesje123';
$config['smtp_port'] = '465';
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('keessonnema@gmail.com', 'Kees Sonnema');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
}
现在我必须配置一个 smtp gmail 控制器?我真的不知道该怎么做。
谢谢