'email has been sent' massage is shown email is not receiving in CodeIgniter - codeigniter

i have use CodeIgniter 2.2.6
i am trying to sent email but i can't get error and not received email
<?php
class email_otp_demo extends CI_Controller
{
public function index()
{
$this->load->library('email');
$config = Array(
'protocol' => 'smpt',
'mailpath' => '/usr/sbin/sendmail,
//'mailpath' => 'www.google.com', also try
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 587,
//'smtp_port' => 456, also try
'smtp_user' => 'my.email#gmail.com',
'smtp_pass' => 'mypassword',
'smtp_timeout'=>50,
'mailtype' => 'text',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE,
'newline' =>'\r\n'
);
// glnlwboynexfjqxj
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->set_crlf("\r\n");
$this->email->from('my.email#gmail.com', 'Social media website');
$this->email->to('sender#yahoo.com');
//$this->email->to('sender#gmail.com'); also try this
// $this->email->cc('another#another-example.com');
// $this->email->bcc('them#their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
echo $this->email->send();
echo "<hr>";
echo $this->email->print_debugger();
}
}
?>
i have get following output but not received email
1
Your message has been successfully sent using the following protocol: mail
User-Agent: CodeIgniter
Date: Sun, 4 Dec 2022 16:53:27 +0530
From: "Social media website" <renish.batada#gmail.com>
Return-Path: <renish.batada#gmail.com>
Reply-To: "renish.batada#gmail.com" <renish.batada#gmail.com>
X-Sender: renish.batada#gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <638c832f6b8c0#gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
=?iso-8859-1?Q?Email_Test?=
Testing the email class.
i have also try to enable and disable to step verification
but not received email
i use app password and original password but not workworking

Related

I am not able to send mail using CodeIgniter email library using amazon SES

I have hosted my domain on amazon ec2 and i have added outbound rules for https (465) and custom tcp (587).
below are my email configuration
$config['email_config'] = [
'mailtype' => 'html',
'protocol' => 'smtp',
'smtp_host' => 'ssl://email-smtp.ap-south-1.amazonaws.com',
'smtp_port' => '587',
'smtp_user' => 'AKIAZJ2TDSA******',
'smtp_pass' => 'B*****N/aBD2mH3nWT4DiOfJ9NI3NRh*******',
'smtp_crypto' => 'tls',
'newline' => "\r\n"
];
And below are email sending code
$this->email->clear();
$this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
$this->email->reply_to($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
$this->email->to('k3#vaksys.com');
$this->email->subject('test subject');
$this->email->message("test");
if ($this->email->send())
{
// echo $this->email->print_debugger();
echo ' sent';
}
else
{
echo 'not sent';
}
According above code, it always goes to if condition.
what is the response from the server ? please put echo $this->email->print_debugger(); in the else{}.
the smtp_host started with ssl:// , the encryption is really done on tls ?
you set mailtype to html and the message not including html body (<html><head><title>test</title></head><body></body>Lorem ipsum dolor sit amet</html>).

login registration and verify email (gmail) codeigniter

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.

i cant send mail codeigniter

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

unable to Send email using codeigniter

I've a registration form and and want to send email to "To Email" and at the same time want to insert user record in db , insertion is successfull but email is not sending using codeigniter here is my code snippet from model and controller resp.
model:
public function add_user()
{
$data=array(
'username'=>$this->input->post('user_name'),
'first_name' => $this->input->post('fname'),
'last_name' => $this->input->post('lname'),
'email'=>$this->input->post('email_address'),
'password'=>md5($this->input->post('password'))
);
return $this->db->insert('user',$data);
//return $data;
}
and here is controller code:
$this->user_model->add_user();
$this->thank();
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'abc#gmail.com',
'smtp_pass' => '******',
'smtp_timeout' => '4',
'mailtype' => 'text',
'charset' => 'iso-8859-1'
);
$this->load->library('email',$config);
$this->email->from('mubbashir.azez#gmail.com');
$this->email->to($data['Email']);
$this->email->subject('test subject');
$this->email->message('hello CI');
$this->email->send();
echo $this->email->print_debugger();
here is view code:
<label for="email_address">Your Email:</label>
<?php echo form_error('email_address','<div class="error">', '</div>');?>
<input type="text" id="email_address" name="email_address" value="<?php echo set_value('email_address'); ?>" />
</p>
print debugger result:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: controllers/user.php
Line Number: 82
A PHP Error was encountered
Severity: Warning
Message: fgets() [function.fgets]: SSL: The operation completed successfully.
Filename: libraries/Email.php
Line Number: 1869
220 mx.google.com ESMTP ea4sm1055346wib.7 - gsmtp
hello: 250-mx.google.com at your service, [139.190.86.52]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
250-ENHANCEDSTATUSCODES
250 CHUNKING
from: 250 2.1.0 OK ea4sm1055346wib.7 - gsmtp
to: 555 5.5.2 Syntax error. ea4sm1055346wib.7 - gsmtp
The following SMTP error was encountered: 555 5.5.2 Syntax error. ea4sm1055346wib.7 - gsmtp
data: 503 5.5.1 RCPT first. ea4sm1055346wib.7 - gsmtp
The following SMTP error was encountered: 503 5.5.1 RCPT first. ea4sm1055346wib.7 - gsmtp
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Wed, 12 Feb 2014 03:26:52 +0500
From: <mubbashir.azez#gmail.com>
Return-Path: <mubbashir.azez#gmail.com>
Subject: =?utf-8?Q?test_subject?=
Reply-To: "mubbashir.azez#gmail.com" <mubbashir.azez#gmail.com>
X-Sender: mubbashir.azez#gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <52faa3ac53dcf#gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_52faa3ac53dd9"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_52faa3ac53dd9
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
hello CI
--B_ALT_52faa3ac53dd9
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
hello CI
--B_ALT_52faa3ac53dd9--
The return value in your model must be
$data
and in your controller code:
replace this
$this->user_model->add_user();
with
$data = $this->user_model->add_user();
You have to put this into your controller:
$data=array(
'username'=>$this->input->post('user_name'),
'first_name' => $this->input->post('fname'),
'last_name' => $this->input->post('lname'),
'email'=>$this->input->post('email_address'),
'password'=>md5($this->input->post('password'))
);
Pass this $data to your model:
$this->user_model->add_user($data);
In your model also write:
add_user($data);
Then change this line also
$this->email->to($data['Email']);
to
$this->email->to($data['email']);

mail codeigniter was sent,but not found in inbox

i was testing to send email by using codeigniter and i successfully send the email,but when i checked my inbox,i didn't find my email i send before.
here's controller:
$this->load->library('email');
$this->email->from('email#yahoo.com', 'my name');
$this->email->to('email#yahoo.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
success message:
Your message has been successfully sent using the following protocol: mail
From: "XXXXXXXXXXXXXX"
Return-Path:
Reply-To: "XXXXXXX#yahoo.com"
X-Sender: XXXXXXX#yahoo.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <XXXXXXX#yahoo.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Testing the email class.
You may check your Spam folder in your email account.
Sometimes gmail/yahoo set email as spam when the mail send from local server.
Try using the following config...
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'your host',
'smtp_port' => 465,
'smtp_user' => 'your email address',
'smtp_pass' => 'password',
'mailtype' => 'html',
'mailpath' => '/usr/sbin/sendmail',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE;
);
$this->load->library('email', $config);
Depending on your server, you should also check your mail server logs to see if the email actually made it off the box. Sometimes you might have success sending it, as the mail is passed to EXIM on your server, but the mail might die in a queue.
If this is a linux box, typically start looking in /var/log/exim4/ etc; (of course depends on your mail server setup).

Resources