Using mail protocol in Codeigniter Received delay after long period - php

Hi I have tried a sample mail function using codeigniter email library it returns successfull on sent email but in my gmail inbox receiving after 16 hours delayed. I dont know why it happens in my particular server. When I tried from other servers it works fine. In mail which is received after 16 hours it shows as received 16 hours ago but not actually received. Below attachment explains you and image of received headers information prepared by google apps. please guide me if any one faces already. I have too fix it soon.
Note : if this question is not related to this forum guide me where to ask.

You can try using google's smtp server instead of your server
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx', //use an email address eg: example#gmail.com
'smtp_pass' => 'xxx', //use the password for your email address
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($sender_email, $sender_name);
$this->email->to($data['email']);
$this->email->subject($subject);
$this->email->message($email_body);
$result = $this->email->send();
Hope it may help

$touser=$email; // email to be sent
$subjectAdmin= "xxx";
$headersAdmin = "From: noreply#domain.com\r\n";
$headersAdmin .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$messageuser ='msg here';
$emailSenduser = mail($touser,$subjectAdmin,$messageuser,$headersAdmin);

Related

Sending Mail Using Gmail In Codeigniter

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.

Outlook for windows/mac showing tags in email

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();

codeigniter send email working but not all the time

this is driving me crazy.... I have just uploaded a site with this email configuration for receiving message from the contact form:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'mail.mysite.com',
'smtp_port' => 587,
'smtp_user' => 'noreply#mysite.com.ar',
'smtp_pass' => 'mypass',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from($data['ct_email'], "contact form");
$this->email->reply_to($data['ct_email']);
$this->email->to("prueba#mysite.com");
$this->email->bcc("noreply#mysite.com.ar"); //copy
$this->email->subject($data['ct_subject']);
$this->email->message($data['ct_message']);
$email = false;
if($this->email->send()){
$email = true;
}
return $email;
As you can see I have a .com and a .com.ar, My server is configured with the .com.ar account but I created an alias with the .com
The problem is that messages arrive in 1 to 10 messages sended...so that means it only works sometimes.
How can I solve this? I have tried changing email addresses but it's all the same...
I keep trying sending messages and it only send sometimes. For the ones that are not sended this is the error displayed:
-0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

SMTP success but the email is not delivered

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!

Email not working in Codeigniter

I am working on booking app in codeigniter. I am stuck in email sending from localhost.
I am using gmail smtp for sending email. I am using email/booking_email.php view file as email template. But, When I run website page that contains email sending script in localhost, it keeps loading but email is not sent.
$email = "atomambition#gmail.com";
$name = "Wiyo HK";
$email_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'atomambition#gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $email_config);
$this->email->from($email, $name);
$this->email->to($this->bookings_class->get_email());
$this->email->reply_to($email, $name);
$subject = 'This is Booking email from Wiyo HK';
$this->email->subject($subject);
$data = array('customer_name' => 'Avash Poudel');
$message = $this->load->view('email/booking_email', $data, TRUE);
$this->email->message($message);
echo $result = $this->email->send();
Localhost does not support sending emails directly unless configured.
In the localhost it does not work like this . For testing use mail() protocol on localhost and smtp on server.
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
Add this in $email_config.
After that you need to initialise your config array.
So write this $this->email->initialize($email_config);
Also use $this->email->print_debugger() to debug

Categories