0

I'm using codeigniter in my project, so what I'm trying to do is to send a simple email using the mail() php function, but nothing happend:

here is my controller (here I call the view email):

public function index()
    {   
        $this->load->helper('url');
        $this->load->view('email'); 
    }

the view email contains:

<form action="<?php echo base_url() ?>email/blog_edit2" method="post" accept-charset="utf-8" enctype="multipart/form-data" >
    <input type="submit" value="create">
</form>

I'm calling blog_edit2 the controller for send the email.

and the code of controller blog_edit2:

public function blog_edit2()
    {

        $this->load->helper('url');

        $to = "example@gmail.com";
        $subject = "My subject";
        $txt = "Hello world!";
        $headers = "From: webmaster@example.com" . "\r\n" .
        "CC: somebodyelse@example.com";

        mail($to,$subject,$txt,$headers);

        $this->load->view("email");

    }

I tested it in both localhost and a real host (free host) but nothing happen, what am I doing wrong? what do I need to configure? thanks

EDIT1: the controller blog_edit2 (using codeigniter email library):

public function blog_edit2()
    {

        $this->load->helper('url');     

        $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'example@gmail.com',
    'smtp_pass' => 'mypass',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");


        $this->email->from('other@gmail.com', 'myname');
        $this->email->to('other@gmail.com'); 

        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');  



    $result = $this->email->send();     

    $this->load->view("email");

    }
user2580401
  • 1,840
  • 9
  • 28
  • 35
  • Have you gone through the codeigniter email library? http://www.codeigniter.com/user_guide/libraries/email.html and also if you are using your email on local host make sure have set up default email at that end as well –  Jun 14 '15 at 02:30
  • yes, I've tried, but can you tell me what is: smtp_host, smtp_user, smtp_pass? where do I get that info? thanks – user2580401 Jun 14 '15 at 02:51
  • Its you host provider email settings http://stackoverflow.com/questions/1555145/sending-email-with-gmail-smtp-with-codeigniter-email-library you also will need to set up email settings on your localhost –  Jun 14 '15 at 02:54
  • It doesn't work using the gmail server and the codeigniter email library why? – user2580401 Jun 14 '15 at 03:17
  • Have you set your localhost email setting need that also –  Jun 14 '15 at 03:25
  • I'm using a real host in byethost, Do I need to configure something? thanks – user2580401 Jun 14 '15 at 03:32

0 Answers0