Sending Emails on godday using codeigniter |
Hello any one out to help, i am kinda having a lot of problems to sending emails when i upload my application to the godaddy servers
So show some code. You probably are forced to use SMTP with Godaddy.
email.php //configurations
<?php $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '7'; $config['smtp_user'] = '[email protected]'; $config['smtp_pass'] = '*************'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['mailtype'] = 'html'; // or html $config['validation'] = TRUE; // bool whether to validate email or not ?> and then sending controller Test controller <?php class Test extends CI_Controller { public function index() { $function = new Users_M(); $email_to = "[email protected]"; $subject = "Test Message"; $message = "message"; $username = "kash";$title="Message"; if($this->sendmail($email_to,$subject,$message,$username,$title,$message)) { echo "Message Sent"; } else { echo "Message NOT Sent"; } } //send email to user public function sendmail($email_to,$subject,$message,$username,$title,$message) { $this->config->load('email', TRUE); $mail_config = $this->config->item('email'); $data = array( 'username'=> $username, 'title' => $title, 'content' => $message, ); $this->load->library('email'); // load email library $this->email->initialize($mail_config); $this->email->set_newline("\r\n"); $this->email->from($mail_config['smtp_user'],$mail_config['website_name']); $this->email->to($email_to); $this->email->subject($subject); $this->email->message($message); if ($this->email->send(FALSE)) return TRUE; else return FALSE; } } ?> |
Welcome Guest, Not a member yet? Register Sign In |