trouble sending email controller |
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**
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] (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);
And are mail() configured on the server? If you are using a VPS you need to configure it yourself.
And if you are on localhost you need to configure it in php.ini
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(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??
You only need to set it if your running on localhost.
Are you sure that your SMTP port number is correct? What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |