I have to write a log in, registration, and restricted members functionality for a site, i everything works but i cant test sending the verification email, but need too. see if it sends and test the verification link in the email.
i am running an Acer Aspire 5920,
Ubuntu 12.04,
Xampp 1.8.1,
Codeigniter 2.1.3
In answer to my own question i needed to pass infomation to configure xampp to send the email:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'gmail.login#googlemail.com',
'smtp_pass' => 'your_password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('gmail.login#googlemail.com', 'Your Name');
$this->email->to('recipient#destination.tld');
$this->email->subject(' CodeIgniter Rocks Socks ');
$this->email->message('Hello World');
if (!$this->email->send()){
show_error($this->email->print_debugger());
}else{
echo 'Your e-mail has been sent!';
}
Related
I have problems when sending email, I make registration and verification by email, when on localhost everything runs smoothly, there are no problems, but when I am hosting, the email function cannot, please help
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'email#gmail.com', // change it to yours
'smtp_pass' => 'mypassword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = "
<html>
<head>
<title>Verifikasi Kode</title>
</head>
<body>
<h2>Terima kasih telah berpartisipasi.</h2>
<p>Akun anda:</p>
<p>Email: ".$email."</p>
<p>Untuk melanjutkan pendaftaran, mohon klik link yang kami berikan</p>
<h4><a href='".base_url()."register/aktivasi/".$id."'>Activate My Account</a></h4>
</body>
</html>
";
$this->email->initialize($config);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($config['smtp_user']);
$this->email->to($email);
$this->email->subject('Signup Verification Email, abcd.com | No reply');
$this->email->message($message);
if($this->email->send()){
$this->session->set_flashdata('msg','Kode Aktivasi telah dikirim ke email, mohon di cek');
}
else{
$this->session->set_flashdata('msg', $this->email->print_debugger());
}
redirect('register',$data);
}
Error : Failed to authenticate password. Error: 534-5.7.14 Please 534-5.7.14 log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 18sm13749594pfp.100 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
This issue causes when your access is wrong.
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com', # Change
'smtp_port' => 587, # Change
'smtp_user' => 'email#gmail.com',
'smtp_pass' => 'mypassword',
'smtp_crypto' => 'tls', # Add
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
Make sure: Less secure apps enabled in Gmail and Turn off 2-Step Verification is turned off
You should change the “Access for less secure apps” to Enabled (it will be disabled, changed to enabled). Try it.
Everything going great on Codeigniter localhost but on particuler Plesk Linux Server I get the different type of error as per changing the port number and protocols. I'm really hanging on this problem, also read the documentation of Plesk but I didn't understand. Hope on StackOverflow someone gives a solution.
I tried most of the all port and protocols to get the result but not succeded. Used code
function sendMail()
{
$this->load->library('email');
// ini_set('SMTP', "smtp.rediffmailpro.com");
// ini_set('smtp_port', "25");
// ini_set('sendmail_from', "myemailid");
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$config = array(
// for rediff mail setup
// 'protocol' => 'smtp',
// 'smtp_host' => 'smtp.rediffmailpro.com',
// 'smtp_port' => 587,
// 'smtp_user' => 'email.com',
// 'smtp_pass' => 'pass',
// 'mailtype' => 'html',
// 'charset' => 'iso-8859-1', //'UTF-8'
// 'wordwrap' => TRUE
// for gmail setup
'protocol' => 'smtp', //'mail', 'sendmail', 'tls' tried these but get different type of errors
'smtp_host' => 'smtp.gmail.com', /*'smtp.googlemail.com',*/
'smtp_port' => 587, //465
'smtp_user' => 'user email',
'smtp_pass' => 'user pass',
//'smtp_crypto' => 'smtp',
'mailtype' => 'html',
'smtp_timeout' => 5,
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->email->initialize($config);
$this->load->library('email', $config);
$this->email->from('email','AG'); // change it to yours
$this->email->to('your email');// change it to yours
$this->email->subject('Test Mail');
$this->email->message('Dont be pannic.');
$this->email->set_newline("\r\n");
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
At this condition I get this error
Failed to authenticate password. Error: 534-5.7.14 Please log
534-5.7.14 in via your web browser and then try again. 534-5.7.14
Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
k11sm2916535wmk.45 - gsmtp Unable to send email using PHP SMTP. Your
server might not be configured to send mail using this method.
But on given google url didn't get any idea about my problem or I didn't get it.
After changing
port 465,
smtp_hot "ssl://email.com",
Get this error
Failed to authenticate password. Error: 534-5.7.14 Please log
534-5.7.14 in via your web browser and then try again. 534-5.7.14
Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
y66sm2047426wmd.37 - gsmtp Unable to send email using PHP SMTP. Your
server might not be configured to send mail using this method.
I don't understand what am I doing wrong.
Want to successfully send mail. On Plesk server
I can't send mail from codeigniter to yandex mail when i using this code:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.yandex.com',
'smtp_port' => 465,
'smtp_user' => 'blablabla#yandex.com',
'smtp_pass' => 'blablabla',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'newline' => "\r\n"
);
$this->load->library('email');
$this->email->initialize($config);
$msg = $this->messages($f2, $f3);
$this->email->to($f1);
$this->email->subject('Here is Subject');
$this->email->message($msg);
if($this->email->send()){
echo "Masuk!";
}else{
echo "Gagal!";
}
echo $this->email->print_debugger();
And the result always says:
Gagal!Cannot send mail with no "From" header.
Cannot send mail with no "From" header.
You simply need to add a From address to your email, by calling
$this->email->from('your#example.com', 'Your Name');
or
$this->email->from('your#example.com');
Depending on the sending and receiving provider, that might get you in trouble though if you try and send the email under another From address, than the one you authenticated against the SMTP server with - it might get classified as spam then (or even rejected by the SMTP server right away) - so in this case here you should use blablabla#yandex.com as From.
you have to set a name and email as a sender.
for example if you set different email and name for sender it shows in inbox mail (Gmail for example) as like below image
I'm trying to run this code :
$this->load->library('email');
$this->email->from('anu1488#gmail.com', 'Anudeep');
$this->email->to('anu1488#gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
When I tried to send, I got this error:
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Filename: libraries/Email.php
Line Number: 1553
What caused this? How can I resolve it?
It sounds like you do not have an SMTP server (mail server) set up on your local machine to send out email. It sounds like the libraries/Email.php file is referencing a hostname/port where a valid mail server does not live.
**I guess you need to setup email configuration and port number in config/email .**
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']='465';
$config['smtp_timeout']='30';
$config['smtp_user']='abhi.abc#gmail.com';
$config['smtp_pass']='password';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['mailtype'] = "html";
**if every thing is correct from your side then you can just change 'smtp_port' number and then check it definitely it will work`enter code here`.**
try this,its working for me....
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'user#gmail.com',
'smtp_pass' => 'user password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('user#gmail.com', 'User');
$this->email->to(sample#gmail.com);
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if ($this->email->send()) {
$data['error'] = "Your email was sent";
} else {
show_error($this->email->print_debugger());
}
then open your php.ini and go to extension=php_openssl.dll and un comment this line .
after that restart ur wamp server.
I have a problem in sending mails using CI. I used the "sendmail" protocol to send mail but it is being filtered as spam. I used the SMTP protocol to solve the problem, but it's not getting sent.
My code is as follows:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '*******#gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$message = "test mail";
$this->email->set_newline("\r\n");
$this->email->from('dsiddharth2#gmail.com', 'St. Maries');
$this->email->to("dsiddharth2#gmail.com");
$this->email->subject('Contact - St. Marians Belguam');
$this->email->message($message);
if($this->email->send())
{
echo "mail sent successfully";
}
else
{
show_error($this->email->print_debugger());
}
When I send the email using "smtp" protocol in CI, I get the following error:
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1673
and other list of errors...
I asked the server admin to enable the "openssl". It's been already taken care of and is enabled.
If you want to try it out, please visit this link and check for yourself.
If it's not working, check your php.ini file. Change this line
;extension=php_openssl.dll
to
extension=php_openssl.dll
It means remove the comment from the line in php.ini file.