Welcome Guest, Not a member yet? Register   Sign In
I am new and in problem - mail library - sending emails using SMTP
#9

[eluser]verynewtothis[/eluser]
Controller
Code:
class Contact extends Controller {

    function __construct()
    {
        //ini_set("SMTP","mail.theServer.com");
        //ini_set("smtp_port",25);
        parent::Controller();    
        $this->load->library('form_validation');
    }
    
    
    function complaints_and_suggestions()
    {
        
            //Create Email - Other Code not shown here
            
            $message = "Following has been received:\n\n";
            $message .= "First Name   : ".$this->input->post('fname')."\n";
            $message .= "Last Name    : ".$this->input->post('lname')."\n";
            $message .= "Email        : ".$this->input->post('email')."\n";
            $message .= "Contact No.  : ".$this->input->post('contact')."\n";
            
            $this->load->library('email');                
            //Send Email to Staff    
            $this->email->from('[email protected]', 'Administrator');
            $this->email->to('[email protected]');                
            $this->email->subject("Some Subject");
            $this->email->message($message);
            
            $this->email->send();
            
            $this->email->clear();
            
            //Send Email to Visitor
            $message = "Respected site visitor.\n\n";
            $message .= "Thank you for submitting your comments\n";
            
            $this->email->from('[email protected]', 'Site Administrator');
            $this->email->to($this->input->post('email'));                
            $this->email->subject("Your Comments");
            $this->email->message($message);
            $this->email->send();
            $this->email->print_debugger();
            
            redirect('contact/success', 'location');
        endif;
    }
}

Email Configuration - from file email.php residing in config directory

Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.theServer.com';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'pass';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;


Messages In This Thread
I am new and in problem - mail library - sending emails using SMTP - by El Forum - 06-29-2009, 06:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB