I am trying to send email from my server with gmail smtp. I am using following code:
$mesaj=$this->load->view('main/mail.php',$token,true);
$config['protocol'] = 'smtp';
$config['wordwrap'] = FALSE;
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'info#site.com';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '465';
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('info#site.com');
$this->email->to($email);
$this->email->subject('Subject');
$this->email->message($mesaj);
$this->email->send();
echo $this->email->print_debugger();
But I am getting following error:
SMTP ERROR OCCURED. AUTH LOGIN COMMAND COULD NOT SEND
I have no SSL certificate on my server. Is this could be the problem ? How can I resolve this problem ?
The port 465 is reserved for SSL requests on the smtp.gmail.com server.
It doesn't look like you specified the authorization method here (none / ssl / tsl).
I'm not too familiar with PHP, so I don't know exactly how you'd set it...
Related
I want to send email using Amazon SES in Codeigniter, i have tried everything, i also tried the earlier questions asked on codeigniter too, but i am not able to find the solution for this.
public function add_applicants()
{
$this->load->model('visa/India_model');
$datan = $this->India_model->insertappdata();
$appid = $datan[appid];
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['charset'] = 'ISO-8859-1';
$config['mailtype'] = 'html';
$config['smtp_host'] = "ssl://email-smtp.eu-west-1.amazonaws.com";
$config['smtp_user'] = "SMTP USER SES";
$config['smtp_pass'] = "SMTP Password SES";
$config['smtp_port'] = "465";
$config['newline'] = "\r\n";
$config['mailsender'] = "support#indiaevisaservice.com";
$config['smtp_crypto'] = 'tls';
$this->email->initialize($config);
$this->email->print_debugger();
$this->email->from('support#verfiedemail.com', 'GYEV Experts');
$this->email->to('imthegrv#gmail.com', 'Test To');
$this->email->subject('Test');
$this->email->message('test');
if($this->email->send()):
print_r($appid);
else:
print_r($this->email->print_debugger());
endif;
}
i am getting error
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
You didn't follow the link provided in the error message, which provides tests that you can use to diagnose your problem.
These three lines are inconsistent:
$config['smtp_host'] = "ssl://email-smtp.eu-west-1.amazonaws.com";
$config['smtp_port'] = "465";
$config['smtp_crypto'] = 'tls';
tls mode will not work on port 465. That should be ssl. Alternatively, change port to 587, and it should be an integer, not a string. There's also no need for the ssl:// prefix on your host; that just adds confusion. First step, change them to this:
$config['smtp_host'] = 'email-smtp.eu-west-1.amazonaws.com';
$config['smtp_port'] = 465;
$config['smtp_crypto'] = 'ssl';
You may still have other issues (e.g. your ISP may block outbound SMTP connections), but there are many other tests listed in the guide that will help you diagnose that.
I have the following code for sending email using codeigniter email library using SMTP using office365 SMTP
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = 'xxxxxx#example.com';
$config['smtp_pass'] = '123456';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['smtp_port'] = 587;
$config['smtp_timeout'] = 60;
$config['smtp_crypto'] = 'tls';
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from('xxxxxx#example.com');
$this->email->to('test123#gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->set_mailtype('html');
$this->email->set_newline("\r\n");
$this->email->send();
And it shows an error
Failed to send AUTH LOGIN command. Error: 504 5.7.4 Unrecognized
authentication type [SG2PR0601CA0010.apcprd06.prod.outlook.com]
Unable to send email using PHP SMTP. Your server might not be
configured to send mail using this method.
In office365,shows configuration like bellow
NOTE: It is using office365 SMTP not gmail
Just use this line of code in your config file code:
$config['protocol'] = 'sendmail';
instead of
$config['protocol'] = 'smtp';
Hopefully, it will solve the error.
Please see my email sending code below and it is showing the following error while sending the email..
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
My Controller:
$from_email= "******";
$to_email = 'dummy#dummy.com';
$subject='Password Reset Request';
$htmlContent = '<p>'.$link.'</p>';
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from($from_email,'*****');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($htmlContent);
$this->email->send();
This condition is showing the above error. Actually, it was working fine initially in development stage, but now it is not..What could have gone wrong in this query...Thank you in advance..
you're using $this->email->initialize($config); but there is no actual configs on your code. And as per your error Unable to send email using PHP mail(), your server can run through sendmail.
Email Class in codeingiter
Example
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
To check outgoing mail with this on server
telnet google.com 25 # 587 or 2095 ,2096
Most server outgoing ports will be 25 or 587
if you are in localhost the code work, are you in live server ?
if your URL is siteurl.domain then try ,
$from_email= "email#siteurl.domain"; //from email must be from same server url
$to_email = 'dummy#dummy.com';
$subject='Password Reset Request';
$htmlContent = '<p>'.$link.'</p>';
//{INCLUDE SMTP CONFIG HERE IF THIS NOT WORKiNG THIS METHOD}
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes
$this->email->initialize($config);
$this->email->from('$from_email', 'sender name');
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($htmlContent);
$this->email->send();
else try with SMTP:),
//SMTP CONFIG
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name
$config['smtp_port'] = '465'; //smtp port number
$config['smtp_user'] = 'ji******#gmail.com';
$config['smtp_pass'] = '*******'; //$from_email password
//Continue above code
I'm not able to comment(sorry) :),
sometimes SMTP method not working with Bluehost account :(
I have the below code for sending email, and on this I am getting SMTP error.
The following SMTP error was encountered: 10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Unable to send data: AUTH LOGIN
It is a very long error I have just provided the upper part.
CODE.
$frommail = "sharadrsoni#gmail.com";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'sharadrsoni#gmail.com';
$config['smtp_pass'] = 'pass'; //your smtp password
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$this->email->initialize($config);
$this->email->from($frommail, $companyfullname);
$this->email->to($tomail);
$this->email->subject($subject);
$this->email->set_mailtype('html');
$this->email->message($MHtml);
$emailSent = $this->email->send();
I have tried couple of ways but ended showing this error only.
I am using CodeIgniter version: 2.1.0
I am having the following code
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","587");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';
$config['_smtp_auth']=TRUE;
$config['smtp_user'] = 'sender#gmail.com';
$config['smtp_pass'] = 'password';
$config['smtp_timeout'] = '60';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->from('sender#gmail.com', 'Sender');
$this->email->to('receiver#gmail.com');
$this->email->subject('This is my subject');
$this->email->message('This is the content of my message');
if ( ! $this->email->send())
{
show_error($this->email->print_debugger());
}
else
{
echo('DONE');
}
But when the code executes, I am getting the following error
Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. qd9sm8462833pbb.31
I have used
$this->load->library('email');
in my controller's constructor. But I am unable to send email from localhost. What can be the solution to send email? What changes do I need to make?
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
I think you should set "Enable IMAP" option in your Gmail account.
It is in the Mail options.
And change your port to 465 ...
$config['smtp_port'] = '587';
to
$config['smtp_port'] = '465';
Add:
$config['smtp_crypto'] = 'tls'; // or html