Codeigniter - 如何使用动态发件人的codeigniter接收或发送电子邮件

时间:2017-12-01 03:50:51

标签: php codeigniter email web gateway

请帮我使用codeigniter完成我的电子邮件网关

我遇到了问题,我想收到发件人(任何人)发来的电子邮件给我的电子邮件 如果我发送该代码,电子邮件将从我发送

但我希望电子邮件应该从个人发送到我的电子邮件

控制器

public function prosespengiriman()
    {
       $this->load->helper(array('form', 'url'));
       $this->load->library('email');

       //konfigurasi email
       $config = array();
       $config['charset'] = 'utf-8';
       $config['useragent'] = 'Codeigniter'; 
       $config['protocol']= "smtp";
       $config['mailtype']= "html";
       $config['smtp_host']= "ssl://smtp.gmail.com";
       $config['smtp_port']= "465";
       $config['smtp_timeout']= "5";
       $config['smtp_user']= "myemail@gmail.com";              
       $config['smtp_pass']= "mypass";            
       $config['crlf']="\r\n";
       $config['newline']="\r\n";
       $config['wordwrap'] = TRUE;

       $this->email->initialize($config);

       $this->email->from($this->input->post('from'));
       $this->email->to('myemail@mail.com');
       $this->email->subject($this->input->post('subject'));
       $this->email->message($this->input->post('isi'));

       if($this->email->send()){
        echo "tutorial pengiriman email berhasil";
       }else{
        echo "tutorial pengiriman email gagal";
       }

      }

有一个视图 - > content_contact.php

 <table>
   <?php echo form_open_multipart('email/prosespengiriman'); ?>
   <tbody>

    <tr>
     <td>Dari</td>
     <td><input type="email" name="from"></td>
    </tr>
    <tr>
     <td>Subject / judul</td>
     <td><input type="text" name="subject"></td>
    </tr>
    <tr>
     <td>Isi Pesan</td>
     <td><textarea name="isi"></textarea></td>
    </tr>

     <td></td>
     <td><input type="submit" value="Kirim"></td>
    </tr>
   </tbody>
   <?php echo form_close();?>
  </table></body>

还有控制器Email.php

0 个答案:

没有答案