dongque4778 2016-02-16 11:03
浏览 70
已采纳

CodeIgniter电子邮件发送问题

I'm created this email sending form, it worked until I change the code to this (this is my controller):

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("
");


    $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());
    }

}

and the HTML/PHP part:

<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>

After Submit it gest a: Message: Call to undefined method CI_Email::contact() also in phone etc.

Thanks for the helps in advance!

  • 写回答

1条回答 默认 最新

  • dtmsaqtly798322992 2016-02-16 11:46
    关注

    There's no contact/phone method in email library. Should be a part of your message, so you need to do something like that:

    $this->email->message($this->input->post("message") .
    "<br><b>Phone:</b> " . $this->input->post("phone") . 
    "<b><b>Contact:</b>" . $this->input->post("contact"));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么