php - Codeigniter & PHPMailer -
so i've been trying day or 2 now. @ first, tried built in codeigniter smtp mail class, no luck. in hope of fixing problem, turned phpmailer. , disappointment, there still no luck.
i'm details correct. i've tried multiple smtp servers, of include gmail , mandrill.
here's code using (i have tried many different modified versions of this, i'll give 1 i'm using)
<?php class thankyou extends ci_controller { function index() { $this->load->model('index'); $header = array( 'title' => 'please confirm', 'navigation' => $this->index->loadnavigation(), ); $this->load->view('header', $header); $this->load->library('my_phpmailer'); $mail = new phpmailer(); $mail->issmtp(); // set mailer use smtp $mail->host = 'smtp.mandrillapp.com'; // specify main , backup server $mail->port = 587; // set smtp port $mail->smtpauth = true; // enable smtp authentication $mail->username = 'email@outlook.com'; // smtp username $mail->password = 'password4mandrill'; // smtp password $mail->smtpsecure = 'tls'; // enable encryption, 'ssl' accepted $mail->smtpdebug = 1; $mail->from = 'hello@whatever.co.uk'; $mail->fromname = 'whatever'; $mail->addaddress('hello@whatever.co.uk', 'josh adams'); // add recipient // name optional $mail->ishtml(false); // set email format html $mail->subject = 'here subject'; $mail->body = 'this html message body <strong>in bold!</strong>'; $mail->altbody = 'this body in plain text non-html mail clients'; if(!$mail->send()) { echo 'message not sent.'; echo 'mailer error: ' . $mail->errorinfo; exit; } } } ?>
if need be, can test here
i error 2014-06-09 11:18:40 smtp error: failed connect server: connection timed out (110) smtp connect() failed. message not sent.mailer error: smtp connect() failed.
try this:
$this->load->library('email'); $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.mandrillapp.com'; $config['smtp_user'] = 'email@outlook.com'; $config['smtp_pass'] = 'password4mandrill'; $config['smtp_port'] = 587; $this->email->initialize($config); $this->email->from('you@outlook.com'); $this->email->to('dest@mail.com'); $this->email->subject('test'); $this->email->message('message'); if($this->email->send()) { echo 'sent'; } else { $this->email->print_debugger(); }
full list of options: http://ellislab.com/codeigniter/user-guide/libraries/email.html
Comments
Post a Comment