I have configured the email function in my Codeigniter application with the following...
$config = [
'protocol' => 'smtp',
'smtp_host' => 'smtp.xxxxx.com',
'smtp_user' => 'xxxxx',
'smtp_pass' => 'xxxxx',
'newline' => "\r\n",
'smtp_port' => 587,
'mailtype' => 'html',
'charset' => 'UTF-8'
];
And sending using...
$sub = 'KONERU Created Sucessfully';
$msg = '<p><a href="koneru.com" >KONERU</a> - Has been Created Sucessfully!</p>';
$msg .= '<br><br><br><p>This mail Generated by computer.<br>Please Don\'t replay to this mail.</p>';
$this->load->library('email', $config);
$this->email->from('xxxxxxxxx','xxxxxxx xxxxxx');
$this->email->to('xxxxxxxxxxxxxx');
$this->email->subject($sub);
$this->email->message($msg);
$this->email->send();
Am able to send an email, but I didn't see HTML format properly on Outlook inbox, I am seeing something like this...
KONERU - Has been Created Su=essfully!
This mail Generated by c=mputer.
Please Don't replay to this mail.
I don't know why, I am seeing some '=' in-between text, I tried with different charset like UTF-8, iso-8859-1 but nothing seems to work.
If I use mailtype = 'text', then if I tried to send a plain text without HTML tags, I didn't see any '=' in between text.
Yes, finally! by adding...
$this->email->set_crlf( "\r\n" );
to configuration, solved my problem.
Related
I will try to send mail using gmail in codeigniter. I write code as given bellow. When i upload it on c panel it will work properly for 2 days but after that it stop working.
//Load email library
$this->load->library('email');
//SMTP & mail configuration
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxxxx',
'smtp_pass' => 'xxxxxx',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->email->initialize($config);
$this->email->set_mailtype('html');
$this->email->set_newline("\r\n");
//Email content
$htmlContent = '<h1>MY WEBSITE</h1>';
$htmlContent .= '<p>OTP For Reset Your Password.</p>';
$this->email->to($uemail);
$this->email->from('xxxxxxxx','MyWebsite');
$this->email->subject('MESSAGE');
$this->email->message($htmlContent);
//Send email
$this->email->send();
I experienced the same thing where the email was not sent and there was no error, it turned out that when I checked my Gmail account it wasn't always on the Primary tab (make sure it wasn't in the Spam folder either). Sent but in the Promotions tab.
I am sending an email to verify user. Email are working fine when opened in browser website, when checked in browser it looks fine. For example when email is send to gmail or any other email site, it does not shows tags but when I open it in outlook 2013, it shows html tags.I don't want outlook to show tagplease help
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.brianvest.com.',
'smtp_port' => 465,
'smtp_user' => 'admin#brianvest.com', // change it to yours
'smtp_pass' => 'voting2016', // change it to yours
'charset' => 'iso-8859-1',
'mailtype' => 'html',
);
$this->load->library('email', $config);
$this->email->set_header('MIME-Version', '1.0; charset=utf-8');
$this->email->set_header('Content-type', 'text/html');
$this->email->from('info#senduleads.com', "Julie Italiano - Modern Office Methods");
$this->email->to($email);
//$this->email->message("Dear Voter,\nPlease click on the URL below, or copy and paste it into your browser to verify your Email Address and Start Voting.\n\n http://www.example.com/JumpStartBeta/".$verificationText."\n"."\n\nThanks,\nJulie Italiano\nModern Office Methods");
$link = "http://example.com/Admin/change_password/$verificationText";
$title = 'Password Change Request for Jump Start Voting';
$this->email->message("Dear Voter,<br>Please click <a href='".$link."'>here</a> to verify your password.<br><br><br>Thanks,<br>Julie Italiano\nModern Office Methods");
$this->email->subject($title);
$this->email->send();
I'm a newbie to CodeIgntier. I'm trying to setup SMTP on CodeIgniter. I receive a success message on page but email is not delivered. Can somebody help me?
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx#gmail.com',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->from('xxx#gmail.com', 'Admin Team');
$sendTo = $this->input->post('email');
$message= 'Hello';
$this->email->to($sendTo);
$this->email->subject('Verification Email');
$this->email->message($message);
if($this->email->send()){
echo "Success";
}
You have mentioned xxx#gmail.com. In google there is Security protection call 2-Step Verification. Make sure its there,If there remove it and try
There is no fault in your code. . To remove it check this link
your code seems ok, make sure your server has openssl extension up and running , and check your firewall for the used smtp port (465 in your case). I would also recommend you using the third party library phpmailer from https://github.com/ivantcholakov/codeigniter-phpmailer whic (mostly for sending html in your message and links )
cheers!
I am trying to send HTML emails with Codeigniter's email class. This is how I am doing it:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'a#a.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->from('b#b.com', 'Me');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($html);
$this->email->set_newline("\r\n");
if($this->email->send()){
return true;
}else{
return false;
}
However, when I view the email in Gmail or outlook, I see bunch of HTML appearing as text at the top of the email and the rest of the email is displayed normally.
Here is the HTML I am sending, its a template that I found to test with. Lines 1 to 19 appear as normal text and is not rendered.
This is how the email looks.
Why is this the case?
As a summary of our conversation in the question's comments, the problem appears to be the content of the $html variable. The variable contains entity encoded HTML. Running it through html_entity_decode solved the problem.
HTML code not rendered seems to be the header of your template. Maybe Gmail will display only the code found inside the tag body, since Gmail is a web application, so it's displayed in a webpage already containing a header and a body (<html><head><body>).
I use CI library for sending HTML email through smtp. When i try to send from my computer, it send right HTML. but when i send it from server, why i get HTML tag. not formatted as html ? I already set 'mailtype' to 'html'.
I wonder why it work at my local but not at server. Is there any configuration in php ? or i should send email header or something?
public function index()
{
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'tls://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxx',
'smtp_pass' => 'xxxx',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->load->library('email', $this->config->item('email'));
$this->email->set_newline("\r\n");
$this->email->from('xxxx', 'xxxx');
$this->email->to("xxxx");
$this->email->subject('Test Email');
$body = $this->load->view('welcome_message',null,TRUE);
$this->email->message($body);
if (!$this->email->send()){
echo 'fail to load email';
}
else {
echo 'success to send email';
}
}
Setting config options doesn't work unless you initialize them. Add this after your $config array:
$this->email->initialize($config);
Based on what I think you're trying to do:
$this->load->library('email', $this->config->item('email'));
should be
$this->load->library('email', $config);
Try and let us know.