联系表单邮件不发送codeigniter

时间:2017-04-06 11:11:36

标签: codeigniter

您好我在codeigniter更新..在我的网站上我添加联系表格并发送邮件给gmail。我在我的本地xampp服务器上尝试这个工作正常。但是一旦我在godaddy服务器上托管,我就会收到类似的错误     严重性:警告     消息:fsockopen():无法连接到ssl://smtp.gmail.com:465(连接超时)     文件名:libraries / Email.php     行号:2063

这是我的观看代码:

<div id="contactform">
            <form id="contact" action="contactform" method="post">
              <fieldset>
              <div class="row">
                <div class="five columns">
                  <label for="name" id="name_label">Your Name: <span class="required">*</span></label>
                  <input type="text" name="name" id="name" size="50" value="" class="text-input" required=""/>
                  <label for="email" id="email_label">Your Email Address: <span class="required">*</span></label>
                  <input type="email" name="email" id="email" size="50" value="" class="text-input" required/>
                  <label for="subject" id="subject_label">Subject</label>
                  <input type="text" name="subject" id="subject"  value="" class="text-input" />
                </div>
                <div class="seven columns">
                  <label for="msg" id="msg_label">Your Message: <span class="required">*</span></label>
                  <textarea cols="60"  name="msg" id="msg" class="text-input" required></textarea>
                  <br />
                  <input type="submit" name="submit" class="button" id="submit_btn" value="Send Message"/>
                  <br class="clear" />
                </div>
              </div>
              </fieldset>
            </form>
        </div>

这是我的控制器代码

public function contactform(){

             //get the form data
            $name = $this->input->post('name');
            $from_email = $this->input->post('email');
            $subject = $this->input->post('subject');
            $message = $this->input->post('msg');

            //set to_email id to which you want to receive mails
            $to_email = 'antoalexander@gmail.com';

            //configure email settings
             $config['protocol'] = 'smtp';
                $config['smtp_host'] = 'ssl://smtp.gmail.com';
                $config['smtp_port'] = '465';
            $config['smtp_user'] = 'antoalexander@gmail.com';
            $config['smtp_pass'] = 'xxxxxxx';
            $config['mailtype'] = 'html';
            $config['charset'] = 'iso-8859-1';
            $config['wordwrap'] = TRUE;
            $config['newline'] = "\r\n"; //use double quotes
            //$this->load->library('email', $config);
            $this->email->initialize($config);                        

            //send mail
            $this->email->from($from_email, $name);
            $this->email->to($to_email);
            $this->email->subject($subject);
            $this->email->message($message);
            if ($this->email->send())
            {
                // mail sent
                $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Thanks For Contacting Us! We Will Contact You Very Soon..</div>');
                $this->load->view('layouts/head');  
            $this->load->view('contact');
            $this->load->view('layouts/footer');
            }
            else
            {
                //error
                $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">There is error in sending mail! Please try again later</div>');
                 $this->load->view('layouts/head'); 
            $this->load->view('contact');
            $this->load->view('layouts/footer');
            }

        }

0 个答案:

没有答案