Welcome Guest, Not a member yet? Register   Sign In
Sending email using CodeIgniter and sendmail under ubuntu-8.10
#1

[eluser]chotair[/eluser]
Hi Guys

I am completely new to CI and am trying to set up an enquiry form on my web page. Doing some search on this forum I did manage to get it working as per the details in the thread below

http://ellislab.com/forums/viewthread/86518/

and the mails do arrive in my inbox. (sending the mail to my hotmail account does not work though!)

What I noticed was it takes enormous amount of time for the control to return to the form.
the sendmail process is holding up and taking too long to send the mail.

when I do ps aux | grep sendmail I get

root 5299 0.0 0.0 8740 1892 ? Ss 08:04 0:00 sendmail: MTA: accepting connections
www-data 11377 0.0 0.0 1844 500 ? S 11:30 0:00 sh -c /usr/sbin/sendmail -oi -f [email protected] -t
www-data 11378 0.0 0.0 8072 2356 ? S 11:30 0:00 /usr/sbin/sendmail -oi -f [email protected] -t

Once the sendmail process is completed the control return...and the mail is gone through. Does anyone know why its taking so long? Would appreciate any help.
#2

[eluser]umefarooq[/eluser]
read the following detail in user guide of CI

http://ellislab.com/codeigniter/user-gui...email.html
#3

[eluser]chotair[/eluser]
Hi umefarooq

I tried putting in the mailpath in the config which I hadn't put earlier. It still takes a very long time to return the control back.

Do I need to restart the server on any such thing?


Here's my file for ref: -

<?php

class Emailmod extends Model
{
function __construct()
{
parent::Model();
$this->load->library('email');
$this->load->helper('security');
$this->load->helper('email');

}

function index()
{
echo("You cannot access this page directly");
}

function quick($name, $email2, $subject, $message)
{
echo("Name: ".$name."<br />");
echo("Email: ".$email2."<br />");
echo("Subject: ".$subject."<br />");
echo("Message: ".$message."<br />");

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;


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

$this->email->from($email2, $name);
$this->email->reply_to($email2, $name);
$this->email->to('[email protected]');

$this->email->subject($subject);
$this->email->message($message);

$this->email->send();

echo $this->email->print_debugger();
}
}

?&gt;
#4

[eluser]umefarooq[/eluser]
first of all do this all you stuff in controller right now you are doing in Model because every time when you call your site url your controller functions are called first from controller we can call model and its methods.
#5

[eluser]chotair[/eluser]
I put the code that was in my model in the controller itself...but didn't make any difference to the speed

here's my modified controller

&lt;?php

class Test extends Controller{

function Test()
{

parent::Controller();
$this->load->library('email');
$this->load->helper('security');
$this->load->helper('email');


}


function quick()
{

$name = $_POST['name'];
$email2 = $_POST['email2'];
$subject = $_POST['subject'];
$message = $_POST['message'];

/* $this->load->model('emailmod');

$this->emailmod->quick($name, $email2, $subject, $message); */

$data['title'] = 'Quick Enquiry';


echo("Name: ".$name."<br />");
echo("Email: ".$email2."<br />");
echo("Subject: ".$subject."<br />");
echo("Message: ".$message."<br />");

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

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

$this->email->from($email2, $name);
$this->email->reply_to($email2, $name);
$this->email->to('raj.chotai@Sky.com');

$this->email->subject($subject);
$this->email->message($message);

$this->email->send();

echo $this->email->print_debugger();

/*
$this->load->view('header', $data);
$this->load->view('form/success');
$this->load->view('footer');
*/
}

}

?&gt;

The lines in red are the lines I commented to stop loading the model and instead do all that in the Controller itself. Speed stays still the same. Something is taking too long in the sendmail. Donno what?




Theme © iAndrew 2016 - Forum software by © MyBB