This question already has an answer here:
I'm trying to send mail with data using but it's not sending anything and here's my function
public function sendmail($response) {
$this->load->library('email');
$bcc="";
$this->email->from(EMAIL_FROM_EMAIL, EMAIL_FROM_NAME);
$this->email->to("dinacs110@gmail");
if (!empty($bcc)) {
$this->email->bcc($bcc);
}
$this->email->set_mailtype("html");
$this->email->subject("Hello Test");
$this->email->message("body");
$serverList = array('localhost', '127.0.0.1');
if (!in_array($_SERVER['HTTP_HOST'], $serverList)) {
$this->email->send();
}
}
I have make this update but still not sending anything
public function sendmail($response){
require_once('phpmailer_/PHPMailerAutoload.php');
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'dinacs110@gmail.com'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('dinacs110@gmail.com', 'dinacs110@gmail.com');
$mail->addAddress('dinacs110@gmail.com', 'Joe User'); // Add a recipient
$mail->addAddress('dinacs110@gmail.com'); // Name is optional
$mail->addReplyTo('dinacs110@gmail.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
The update code just give me a message on my gmail that someone trying to hack my mail then i have make it's not secure to access the mail but still not having error or even mail !! so what's the error here ?
</div>