SMTP Codeigniter email error '354 End data with .' - codeigniter

I'm having trouble getting the Codeigniter email library working on a new server.
This code has previously worked before but has recently stopped working and I cannot for the life of me figure out why. Essentially, here is the code:
$this->email->from('example#example.com', 'Intranet');
$this->email->to($c['email']);//This is def a valid email
//$name is being obtained from elsewhere
$this->email->subject('Time manager reminder');
$this->email->message("
{$name[0]},
<br/><br/>You haven’t completed your time for today. Please don’t forget to do so<br/><br/>
Intranet
");
$this->email->send();
And the email.php config password
$config['mailtype'] = "html";
$config['priority'] = 1;
$config['protocol'] = "smtp";
$config['smtp_host'] = "my server..";
$config['smtp_user'] = "u/n";
$config['smtp_pass'] = "p/w";
$config['smtp_timeout'] = 1;
$config['validate'] = true;
The error I receive from $this->email->print_debugger(); is as follows:
data: 354 End data with .
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.
You can view the full error on pastebin here http://pastebin.com/y9UeaEGY
I've crossed out the emails in all places, but I can assure you they are valid and used email addresses.
I'd appreciate any help you can offer. Thanks

I figured out the reason. Apparently, in the config, you need to set
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
manually in the email.php file. Codeigniter doesn't seem to do it by default. Odd :)

Related

How can I transform a PHPMailer connection to Laravel .env?

I have a situation where an app is sending its mails with PHPMailer and next configuration:
$mail->isSMTP();
$mail->Host = 'myhost.dev';
$mail->SMTPAuth = false;
$mail->setFrom($from, $from_name);
$mail->addAddress($to, $to_name);
if ($replyTo != '') $mail->addReplyTo($replyTo, $replyToName);
$mail->isHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->Body = $body;
As you can see, SMTP server doesn't require authentication and all is working ok. That's all data I have about the mail server. Now, I need to make the same thing but instead of using PHPMailer I want to implement the sending method of Laravel, but I don't have any authentication credential for setting my .env file.
How can I pass the same configuration to my Laravel development? I've tried many combinations but nothing happens. This was the last one:
MAIL_DRIVER=smtp
MAIL_HOST=myhost.dev
MAIL_PORT=25
MAIL_USERNAME=no-reply#host.com
MAIL_PASSWORD=''
MAIL_ENCRYPTION=''
PHPMailer has no idea about Laravel, so you need to pass through the information yourself. Laravel provides the env() global function to retrieve data from the environment, and you would use it like this:
$mail->Host = env('MAIL_HOST');
if (!empty(env('MAIL_USERNAME')) {
$mail->SMTPAuth = true;
$mail->Username = env('MAIL_USERNAME');
$mail->Password = env('MAIL_PASSWORD');
}
and so on, for any other configuration variables you need. I'm not sure exactly what Laravel package defines the env function, but you will need to make sure it's loaded and within scope before calling it.

why is codeigniter email not functional for abc#company.com.np

I am using codeigniter email. Everything is correct except that mail isn't sent to my client email which is something like abc#companyname.com.np but goes to gmail and my office mail.I have bulk email ids to send to. Have I done something wrong or is it the problem of client's company mail settings ??
$this->load->library('email');
$config['mailtype'] = 'html';
$config['validate'] = TRUE;
$this->email->initialize($config);
$this->email->from('abc#gmail.com', 'ABCTechnologies');
$list = array($form->admin_email);
$this->email->to($list);
$this->email->subject($form->form_title);
$message = 'You have got a new Feedback. Here are the Details : <br/>';
'.$email_fields['message'].'<br/>';
$this->email->message($message);
$this->email->send();
where $list is array of mail id.Any suggesstions are welcome.
I changed the smtp also but to no avail.
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.sipradi.com.np';
and smtp port is by default 25.
Help

mail() on https

I setup a website that uses PHP mail(). I can get it to successfully run if I hit the script on http:// but if I switch to https:// it does not work! I use Godaddy for hosting and have a certificate purchased through them. I am not sure if I need to setup anything in the php.ini file or not. My mailscript looks like this:
$from_respondent_email = "calendar#mydomain.com" ;
$headers_respondent_email = "From: $from_respondent_email";
$subject_respondent_email = "Technical Support Request";
$body_respondent_email = "We received a support ticket from mydomain.com:\n\n";
$body_respondent_email .= "Test block of text";
$send = mail("myname#gmail.com", $subject_respondent_email, $body_respondent_email, $headers_respondent_email);
$to ="myname#gmail.com";
$subject = "Technical Support Request";
$message = "We received a support ticket from mydomain.com:\n\n";
$from = "calendar#mydomain.com";
$headers = "From: $from_respondent_email";
mail($to,$subject,$message,$headers);
Try this. It'll work. I used this in my website and its working :)

CakePHP email not sending but showing in debug mode

My CakePHP should send an email when a button is clicked, however it doesn't. Also, the email will be displayed as a flash message if I run it in debug mode: ($this->Email->delivery = 'debug';).
Note: Email is set up to set up to use PHP mail() function.
Code to call the email function:
$this->_sendUpdateEmail( $this->Auth->user('id'), $about_id );
Email function
function _sendUpdateEmail($from_user_id, $about_id) {
$fromUser = $this->User->read(null, $from_user_id);
$users = $this->User->find('all', array(
'conditions' => array('User.distribution =' => 1)
));
# loop to send email to all users who are marked as on the distribution list
for($i = 0, $size = sizeof($users); $i < $size; ++$i) {
$user = $users[$i]['User'];
$this->Email->from = $fromUser['User']['email'];
$this->Email->replyTo = $fromUser['User']['email'];
$this->Email->to = $user['email'];
$this->Email->subject = 'Test email';
$this->Email->template = 'update';
$this->Email->sendAs = 'both'; // both = html and text
$this->set('user', $user);
$this->set('about', $about_id);
$this->Email->send();
$this->Email->reset();
}
}
Any ideas as to why the emails show in debug mode but won't actually send?
I think the reason why my emails were not sending was because there was no mail server configured on the web server my CakePHP was running on so there was no way to route the emails. However, this meant they would show up in the debug because they were generated successfully, just not sent.
In the end, I ended up using my company's Exchange mail server using the SMTP settings.
Code to use SMTP to send CakePHP emails
$this->Email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => '192.168.0.244',
);
// Other email code here, e.g. from and to etc...
$this->Email->delivery = 'smtp';
I think the issue here is that mail server is not set right Linux comes built in with mail sending functionality but not windows (no idea on mac). look into smtp options as u can easily setup smtp email sender on Windows
Setting up smtp windows - http://publib.boulder.ibm.com/infocenter/cqhelp/v7r1m2/index.jsp?topic=/com.ibm.rational.clearquest.webadmin.doc/topics/c_config_email_smtp_win.htm
and
http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP

Code Igniter email config to config.php

I've put my email configurations in the config.php but I don't know how I can access them in my controller.
In my config.php:
/*EMAIL CONFIG*/
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'username';
$config['smtp_pass'] = 'pass';
$config['smtp_port'] = '465';
$config['mailtype'] = 'html';
Should I make an instance of the super global object?
Thanks in advance.
You don't put email config settings in config.php. You make a new file called email.php and place it in the config folder. CI will automatically detect the email config setting from that file.
Look under "Setting Email Preferences in a Config File"
http://ellislab.com/codeigniter/user-guide/libraries/email.html
You can access it with:
$this->config->item('protocol');
Also, see the relevant chapter in CodeIgniter User Guide

Resources