2016-10-21 16 views
0

私はCodeIgniterにある私のウェブサイトの私達に連絡先のページを作成しています。この連絡フォームデータを自分のメールアドレスに送信したいと思います。codeigniterのウェブサイトでSMTPプロトコルを使用せずにメールを送信する方法

WebサイトでSMTPを使用せずにCodeIgniterで電子メールを送信するにはどうすればいいですか?

+1

はいおお、 'PHPのメールfunction'を使用 – Karthi

答えて

0

はい、codeIgniterの簡易メール機能を使用できます。

例: -

public function send_mail() { 
     $from_email = "[email protected]"; 
     $to_email = $this->input->post('email'); 

     //Load email library 
     $this->load->library('email'); 

     $this->email->from($from_email, 'Your Name'); 
     $this->email->to($to_email); 
     $this->email->subject('Email Test'); 
     $this->email->message('Testing the email class.'); 

     //Send mail 
     if($this->email->send()) 
     $this->session->set_flashdata("email_sent","Email sent successfully."); 
     else 
     $this->session->set_flashdata("email_sent","Error in sending Email."); 
     $this->load->view('email_form'); 
     } 
0

あなたは電子メールを送信することができます。
コントローラ。

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class Inquiry extends CI_Controller 
{ 
    public function inquiry() 
    { 
     parent::__construct(); 
     /* Model */ 
    } 

    public function index() 
    { 
     $this->load->view('header', array("title" => "Inquiry")); 
     $this->load->view('your_view',$view); 
     $this->load->view('footer'); 
    } 

    function inviteStaff() 
    { 
     $this->load->library('email'); 
     $from_email = $_POST['email']; 
     $to_email = "[email protected]"; 
     $body='이름 : '.$_POST['name'].'<br /><br />email : '.$_POST['email'].'<br /><br />contents : '.$_POST['contents'].''; 

     $this->email->from($from_email, $_POST['name']); 
     $this->email->to($to_email); 
     $this->email->set_mailtype("html"); 
     $this->email->subject('TITLE'); 
     $this->email->message($body); 
     $this->email->send(); 
    } 

    function emailCheck() 
    { 
     $user_id = base64_decode($_POST['user_id']); 
     $email = $_POST['check_mail']; 
     $where = array('user_emailId' => $email,'user_id!=' => $user_id); 
     $view = $this->mdl_file->sel_where('user_details',$where); 
     echo count($view); 
    } 
} 

view。

<form class="form-horizontal form-label-left" method="POST" action="<?php echo base_url();?>Inquiry/inviteStaff"> 
 
    <div class="item form-group" id="email_div"> 
 
    <label class="control-label col-md-3 col-sm-3 col-xs-3 right" for="name">이름<span class="required">*</span> 
 
    </label> 
 
    <div class="col-md-6 col-sm-6 col-xs-6" > 
 
    <input type="text" id="name" name="name" required="required" class="form-control col-md-7 col-xs-12" placeholder="이름" onblur="return emailCheck();" value="<?php echo @$staff_details[0]['user_emailId'] ?>"> 
 
    </div> 
 
    <div class="alert">Your Name.</div> 
 
    <div class="alert_1" style="position: absolute;margin-left: 735px;width: 160px;display: none;margin-top: 5px;color: red;"> 
 
    </div> 
 
    </div> 
 
    <div class="item form-group" id="email_div"> 
 
    <label class="control-label col-md-3 col-sm-3 col-xs-3 right" for="email">E-mail<span class="required">*</span></label> 
 
    <div class="col-md-6 col-sm-6 col-xs-6" > 
 
    <input type="text" id="email" name="email" required="required" class="form-control col-md-7 col-xs-12" placeholder="Email" onblur="return emailCheck();" value="<?php echo @$staff_details[0]['user_emailId'] ?>"> 
 
    </div> 
 
    <div class="alert">Your Email.</div> 
 
    <div class="alert_1" style="position: absolute;margin-left: 735px;width: 160px;display: none;margin-top: 5px;color: red;"> 
 
    </div> 
 
    </div> 
 
    <div class="item form-group" id="email_div"> 
 
    <label class="control-label col-md-3 col-sm-3 col-xs-3 right" for="contents">내용<span class="required">*</span></label> 
 
    <div class="col-md-6 col-sm-6 col-xs-6" > 
 
     <textarea id="contents" name="contents" required="required" class="form-control col-md-7 col-xs-12" placeholder="내용" onblur="return emailCheck();" value="<?php echo @$staff_details[0]['user_emailId'] ?>" style="height:200px"> 
 
     </textarea> 
 
\t </div> 
 
\t <div class="alert">Contents.</div> 
 
\t <div class="alert_1" style="position: absolute;margin-left: 735px;width: 160px;display: none;margin-top: 5px;color: red;"> 
 
     </div> 
 
\t </div> 
 
</form>

関連する問題