Codeigniter Config:
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'shahrushabh1996#gmail.com';
$config['smtp_pass'] = '####';
$config['smtp_port'] = 465;
Codeigniter Controller:
$this->load->library('email');
$this->email->from('shahrushabh1996#gmail.com', 'Webers Infotech');
$this->email->to('shahrushabh1996#gmail.com','Rushabh Shah');
$this->email->subject('Your Subject');
$this->email->message('Your Message');
if (!$this->email->send()) {
show_error($this->email->print_debugger());
}
Can anyone please tell me How can I resolve this issue? Why is it not working?
You can check with the following code:
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.app.com'; // if via gmail 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'email#dmail.com';
$config['smtp_pass'] = 'smtp password';
$config['smtp_port'] = port number;
$config['starttls'] = TRUE;
$this->email->initialize($config);
$this->email->from('youremail#domain.com');
$this->email->to('to#domain.com');
$this->email->subject('testing');
$this->email->message('Message content');
if($this->email->send()) {
echo 'Message has been sent';
} else {
$this->email->print_debugger();
}
Also check the php_smtp.dll . Is that available or not.
To check that you can use
<?php
phpinfo();
?>
If not found then check on php.ini file and there should be a line as
;extension=php_extname.dll
just remove the ; from this line and restart php service ( restart Apache ).
Related
Please help, send email error using SMTP Outlook 365.
previously it was still able to run, but suddenly an error.
these my code
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = 'XXX#XXXX.com';
$config['smtp_pass'] = '#########';
$config['smtp_port'] = '587';
$config['smtp_crypto'] = 'tls';
$config['starttls'] = FALSE;
$config['smtp_timeout'] = '5';
$config['wordwrap'] = TRUE;
$config['charset']='iso-8859-1';
$config['mailtype'] = 'html';
$config['newline']="\r\n";
$config['crlf']= "\r\n";
$this->email->initialize($config);
//Email content
$htmlContent = 'XXX';
$htmlContent .= 'XXX';
$this->email->to('XXX#XXXX.com');
$this->email->from('XXXXX#XXXXX.com','MyWebsite');
$this->email->subject('How to send email via SMTP server in CodeIgniter');
$this->email->message($htmlContent);
//Send email
$this->email->send();
if($this->email->send())
{
echo "Email sent!!";
} else {
echo "Email is not sent!!";
echo $this->email->print_debugger();
}
}
and these an error result
Following is given the code, need help. I have the Goddady server, but I am not able to send mail.
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['SMTP_Secure'] = 'ssl';
$config['smtp_server'] = 'relay-hosting.secureserver.net'; //smtp.gmail.com
$config['smtp_host'] = 'smtp.gmail.com'; //smtp.gmail.com
$config['smtp_port'] = '465'
$config['smtp_user'] = '....#gmail.com';
$config['smtp_pass'] = '******';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'text'; // or html
$config['validation'] = true; // bool whether to validate email or not
$this->email->initialize($config);
$this->email->from('....#gmail.com', 'sender_name');
$this->email->to('....#gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.'); if($this->email->send())
{
echo "Working"; echo $this->email->print_debugger();}else{echo "Not working";
}
I am using this code to send email via localhost.
function send_email(){
date_default_timezone_set('Asia/Manila');
$ci =& get_instance();
$ci->load->library('email');
$config['protocol'] = "mail";
$config['smtp_host'] = "ssl://mail.smsgt.com";
$config['smtp_port'] = "25";
$config['smtp_user'] = "myemail#smsgt.com";
$config['smtp_pass'] = "";
$config['charset'] = "utf-8";
$config['mailtype'] = "text";
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('sender#email.com', 'company email');
$ci->email->to('receiver#gmail.com');
$ci->email->subject('test subject');
$ci->email->message("testing email");
$check = $ci->email->send();
//echo $ci->email->print_debugger();
if ($check){
echo "true";
}else{
echo "false";
}
}
It always shows true but still I cant received it. What is problem with my codes? or is there something wrong?
**Your smtp and port is not working**
$config['smtp_host'] = "ssl://mail.smsgt.com";
$config['smtp_port'] = "25";
**Change into this**
$config['smtp_host'] = "ssl://smtp.mail.yahoo.com;ssl://smtp.gmail.com";
$config['smtp_port'] = 465;
I am having the following code
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","587");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';
$config['_smtp_auth']=TRUE;
$config['smtp_user'] = 'sender#gmail.com';
$config['smtp_pass'] = 'password';
$config['smtp_timeout'] = '60';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->from('sender#gmail.com', 'Sender');
$this->email->to('receiver#gmail.com');
$this->email->subject('This is my subject');
$this->email->message('This is the content of my message');
if ( ! $this->email->send())
{
show_error($this->email->print_debugger());
}
else
{
echo('DONE');
}
But when the code executes, I am getting the following error
Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. qd9sm8462833pbb.31
I have used
$this->load->library('email');
in my controller's constructor. But I am unable to send email from localhost. What can be the solution to send email? What changes do I need to make?
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
I think you should set "Enable IMAP" option in your Gmail account.
It is in the Mail options.
And change your port to 465 ...
$config['smtp_port'] = '587';
to
$config['smtp_port'] = '465';
Add:
$config['smtp_crypto'] = 'tls'; // or html
I tried to send mail using the email class of CodeIgniter, but it is showing some errors:
fsockopen() [function.fsockopen]: unable to connect to
ssl://smtp.googlemail.com:465 (Unable to find the socket transport
"ssl" - did you forget to enable it when you configured PHP?)
My code is here:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'myemail.world2010#gmail.com';
$config['smtp_pass'] = 'email';
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$message="
username:{$this->input->post('username')}
password:{$this->input->post('password')}
";
$this->email->from('sagar.world2010#gmail.com','Admin');
$this->email->to($this->input->post('email'));
$this->email->subject('Activation Message');
$this->email->message($message);
$this->email->send();
echo $this->email->print_debugger();
I also changed the php.ini file and pasted extension=php_openssl.dll in it, but it still does not work.
The smtp server from gmail is smtp.gmail.com
so your configuration should be:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'myemail.world2010#gmail.com';
$config['smtp_pass'] = 'email';
but I'm not sure if smtp_host need the 'ssl://' part