In Config.php File I have changes
$config['protocol']='smtp';
$config['smtp_hostname'] = "ssl://smtp.zoho.com";
$config['smtp_crypto'] = 'tls';
$config['smtp_username'] = "aaaa";
$config['smtp_password'] = "xxx";
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['newline'] = "\r\n";
But MAil Not Send.
enter image description here
Related
I have a email sending code in codeigniter. I am able to send email but the HTML displays tags in the email. I have used mailtype as HTML. But it still does not work. This is my email function.
public function email_send($to_email,$subject,$message,$attach)
{
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'dsouzaj184#gmail.com';
$config['smtp_pass'] = 'abcd#1234';
$config['charset'] = 'UTF-8';
$config['smtp_crypto'] = 'ssl';
$config['priority'] = 1;
//$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$config['crlf'] = '\r\n';
$config['newline'] = '\r\n';
$this->load->library('email',$config);
$this->email->clear(true);
//$this->email->initialize($config);
$this->email->set_mailtype("html");
$this->email->set_header('Content-Type', 'text/html');
//$this->email->set_newline('\r\n');
$this->email->from('dsouzaj184#gmail.com', 'Global Admin');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
// return $to_email;
if($attach != '') {
$this->email->attach($attach);
}
if($this->email->send()) {
$this->email->clear(true);
return 1;
} else {
//print_r($this->email->print_debugger());
return 0;
}
}
Add wordwrap in config array as true
$config['wordwrap'] = TRUE;
and if it wont solve your problem than change
$this->load->library('email',$config);
$this->email->clear(true);
//$this->email->initialize($config);
$this->email->set_mailtype("html");
$this->email->set_header('Content-Type', 'text/html');
//$this->email->set_newline('\r\n');
to
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline('\r\n');
$this->email->clear();
I have database.php in connection from CI
$dbhost = '192.168.1.3'; //IP or server name of my host database
$dbport = '1521'; //Oracle port
$dbname = 'dev'; //TNS Name
$dbConnString = "
(DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ". $dbhost .")(PORT = ". $dbport .")))
(CONNECT_DATA =(SERVICE_NAME = ". $dbname .") ))";
$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = 'abc';
$db['default']['password'] = 'abcpass';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;//FALSE
$db['default']['db_debug'] = TRUE;//FALSE
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
But if i run this program always shown error
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\reset\system\database\DB_driver.php
Line Number: 124
What should i do?
oci8 in php.ini already opened
Try to change default to dev ... your code will be
$db['dev']['hostname'] = $dbConnString;
$db['dev']['username'] = 'abc';
$db['dev']['password'] = 'abcpass';
$db['dev']['database'] = '';
.
.
.
I want to send an email to the user who is verified by the Admin. When the admin clicks on verify button in DB the status of a user is changed and email sends to a user, status can change but the email not send.
AdminController:
if($this->AdminModel->updateUser($id , $status)){
$user_message = "hello";
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'kshahroz699#gmail.com';
$config['smtp_pass'] = 'password';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE;
$this->email->initialize($config);
$this->email->from('kshahroz699#gmail.com', 'Model Hunt Inquiry');
$this->email->to($email);
$this->email->subject('Model Hunt Inquiry Form');
$this->email->message($user_message);
if($this->email->send()) {
echo " Successfully send";
}else{
echo "Not Send";
}
AdminModel:
function updateUser($id, $data){
$this->db->where('id',$id);
return $this->db->update('mh_users',$data);
}
Route:
$route['verifyUserEmail/(:any)/(:any)'] = 'Admin/verifyEmail/$1/$2';
Admin Model
function updateUser($id, $data){
$this->db->where('id',$id);
return $this->db->update('mh_users',$data);
}
My Controller
$this->load->library('email');
if($this->AdminModel->updateUser($id , $status)){
$from = 'no-reply#test.com';
$to = 'test#gmail.com';
$message1 = 'Hello Test';
$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = "localhost";
$config['smtp_port'] = "25";
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from($from, 'Test');
$this->email->to($to);
$this->email->subject('Test');
$this->email->message($message1);
$this->email->set_mailtype('html');
if($this->email->send()){
$message=array("1","Mail Sent Successfully");
}else{
$message=array("0",$this->db->_error_message());
}
}
$this->session->set_flashdata('message', $message);
I am trying to send two emails, each from a different sender. The problem is that the second email is sent from the sender of the first email.
Codeigniter is ignoring the $this->email->from of the second email
$this->load->library('email');
$html="some text";
// send email
$config['mailtype'] = 'html';
$config['protocol'] = "smtp";
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'user#gmail.com';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '465';
$config['newline'] = "\r\n";
$this->email->initialize($config);
$this->email->from('myemail#gmail.com', '');
$this->email->to("someemail#site.com");
$this->email->subject("The subject");
$this->email->message($html);
if($this->email->send()) {
}
$this->email->clear();
$config1['mailtype'] = 'html';
$this->email->initialize($config1);
$this->email->from('thesecondemail#www.com', 'The test');
$this->email->to("user#eee.com");
$html="Some other text";
$this->email->subject("hello some text");
$this->email->message($html);
if($this->email->send()) {
}
I'm using CodeIgniter 3.0.3 and PHPMailer (https://github.com/ivantcholakov/codeigniter-phpmailer).
I have a problem with the configuration because it does not send e-mails.
This is my config file:
<?php defined('BASEPATH') OR exit('No direct script access allowed.');
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'mail.skins4points.pl';
$config['smtp_user'] = 'noreply#skins4points.pl';
$config['smtp_pass'] = 'mypass';
$config['smtp_port'] = 587;
$config['smtp_timeout'] = 5; // (in seconds)
$config['smtp_crypto'] = ''; // '' or 'tls' or 'ssl'
$config['smtp_debug'] = 0; // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['wordwrap'] = true;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html'; // 'text' or 'html'
$config['charset'] = null; // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
$config['validate'] = true;
$config['priority'] = 3; // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449
$config['crlf'] = "\n"; // "\r\n" or "\n" or "\r"
$config['newline'] = "\n"; // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode'] = false;
$config['bcc_batch_size'] = 200;
$config['encoding'] = '8bit'; // The body encoding. For CodeIgniter: '8bit' or '7bit'. For PHPMailer: '8bit', '7bit', 'binary', 'base64', or 'quoted-printable'.
I am using the email account you set up with hekko.pl
Here sample configuration mail client: http://www.pomoc.hekko.pl/content/28/53/pl/konfiguracja-poczty-w-mozilla-thunderbird.html
I'd guess that smtp_crypto needs to be tls if you're talking to port 587.