![]() |
trouble sending email controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: trouble sending email controller (/showthread.php?tid=74530) Pages:
1
2
|
trouble sending email controller - pmcr - 10-05-2019 hi a bit of a novice, but can anyone give me an idea what might be wrong in this code? when submit button is pressed, there is no message or email sent ... Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Thank you **EDIT: code tags added for readability** RE: trouble sending email controller - jreklund - 10-06-2019 Hi, What does $this->send_mail do? As the problem lies there. Do you actually have this in your code, or are that just a copy and paste error? Code: [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif] RE: trouble sending email controller - pmcr - 10-06-2019 (10-06-2019, 02:35 AM)jreklund Wrote: Hi, What does $this->send_mail do? As the problem lies there. I did change the original code which was also not working. $mail=mail($to, $subject, $main_msg, $headers); RE: trouble sending email controller - jreklund - 10-06-2019 And are mail() configured on the server? If you are using a VPS you need to configure it yourself. RE: trouble sending email controller - InsiteFX - 10-06-2019 And if you are on localhost you need to configure it in php.ini RE: trouble sending email controller - pmcr - 10-08-2019 (10-06-2019, 08:04 AM)jreklund Wrote: And are mail() configured on the server? If you are using a VPS you need to configure it yourself.Not using VPS I have another controller where email is sent out without any issue I do have set in core/my_controller the following, and the reason why i had used sent_email instead of email /* Mail Send */ public function send_mail($email, $subject, $message) { $config = array( 'protocol' => 'SMTP', 'smtp_host' => 'mail.xxx.biz', 'smtp_port' => 25, 'smtp_user' => '[email protected]', 'smtp_pass' => 'Test@123##', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE, 'charset' => 'utf-8', 'priority' => '1', ); $this->load->library('email',$config); $this->email->set_newline("\n"); // $this->email->from('[email protected]',"title email"); $this->email->from('[email protected]',"subject"); $this->email->to($email); $this->email->subject($subject); $this->email->message($message); return $this->email->send(); } or even this one public function send_mail_cart($email, $subject, $message) { $this->load->library('PHPMailer/phpmailer'); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "smtp.gmail.com"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "xxxxx@1234"; // SMTP password $mail->SMTPSecure = "tls"; $mail->Port = 587; $mail->From = "[email protected]"; $mail->FromName = "title email "; $mail->AddAddress($email); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; if(!$mail->Send()) { return false; } else { return true; could i adapt any of the above?? RE: trouble sending email controller - pmcr - 10-08-2019 (10-06-2019, 08:11 AM)InsiteFX Wrote: And if you are on localhost you need to configure it in php.inii am running it from live server i can't find any php.ini file in the server Where should it be located? what should be the full command on it if really its the issue RE: trouble sending email controller - InsiteFX - 10-08-2019 You only need to set it if your running on localhost. Are you sure that your SMTP port number is correct? RE: trouble sending email controller - jreklund - 10-08-2019 (10-08-2019, 12:29 AM)pmcr Wrote: I have another controller where email is sent out without any issue Okey, then you need to to debug it by passing in everything manually instead of input->post. Not relying on outside factors. And start from there. RE: trouble sending email controller - pmcr - 10-08-2019 (10-08-2019, 08:55 AM)InsiteFX Wrote: You only need to set it if your running on localhost.Yes. i use it on another controller in which emails are being sent out. |