I try to send mail using SMTP using codeigniter. But get following problem.
Even my credential is correct and work fine while i opened in gmail. After that I got below message.
220 smtp.gmail.com ESMTP uo6sm2505144wjc.1 - gsmtp
hello: 250-smtp.gmail.com at your service, [198.58.84.54]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 uo6sm2505144wjc.1 - gsmtp
from: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
to: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
data: 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 uo6sm2505144wjc.1 - gsmtp
502 5.5.1 Unrecognized command. uo6sm2505144wjc.1 - gsmtp
The following SMTP error was encountered: 502 5.5.1 Unrecognized command. uo6sm2505144wjc.1 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Tue, 11 Aug 2015 11:07:54 +0000
From: "Admin" <sflowask#gmail.com>
Return-Path: <sflowask#gmail.com>
To: pankaj.kumar.k#kindlebit.com
Subject: =?utf-8?Q?Welcome_for_new_signup?=
Reply-To: "sflowask#gmail.com" <sflowask#gmail.com>
X-Sender: sflowask#gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <55c9d78b01533#gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_55c9d78b01d05"
This is a multi-part message in MIME format.
Your email application may not support this format.
You must change $config['protocol'] = "smtp"; to $config['protocol'] = "SMTP";
Let me know if it works for you
Try the following code,may it fixed your issue.It worked perfect for me.
$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = "localhost";
$config['smtp_port'] = "25";
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = TRUE;
$this->load->library('email');
$this->email->initialize($config);
$this->email->message = "Your Message";
$this->email->subject("Message Subject");
$this->email->from("user#gmail.com");
$this->email->to("admin#gmail.com");
$this->email->send();
Related
After I use print debugger to check whether it's sent or not, and here's what I got in return:
bool(false) 220 smtp.gmail.com ESMTP t8sm1776565pgr.21 - gsmtp
hello: 250-smtp.gmail.com at your service, [45.116.123.5]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. t8sm1776565pgr.21 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Fri, 2 Feb 2018 13:02:25 +0530
To: demo#example.com
From: "MyWebsite" <demo#example.com>
Return-Path: <demo#example.com>
Subject: =?UTF-8?Q?How=20to=20send=20email=20vi?==?UTF-8?Q?a=20SMTP=20?= =?UTF-8?Q?server=20in=20CodeIgniter?=
Reply-To: <demo#example.com>
User-Agent: CodeIgniter
X-Sender: demo#example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a741409bc741#gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5a741409bc741"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_5a741409bc741
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sending email via SMTP serverThis email has sent via SMTP server from
CodeIgniter application.
--B_ALT_5a741409bc741
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=3Ch1=3ESending email via SMTP server=3C/h1=3E=3Cp=3EThis email has sent vi=
a SMTP server from CodeIgniter application.=3C/p=3E
--B_ALT_5a741409bc741--
When I changed the smtp_port to 465 and I got in response like
bool(false)
hello: F
The following SMTP error was encountered: F
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Fri, 2 Feb 2018 13:12:43 +0530
To: demo#example.com
From: "MyWebsite" <demo#example.com>
Return-Path: <demo#example.com>
Subject: =?UTF-8?Q?How=20to=20send=20email=20vi?==?UTF-8?Q?a=20SMTP=20?= =?UTF-8?Q?server=20in=20CodeIgniter?=
Reply-To: <demo#example.com>
User-Agent: CodeIgniter
X-Sender: demo#example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a7416736d6ea#gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5a7416736d6ea"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_5a7416736d6ea
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Sending email via SMTP serverThis email has sent via SMTP server from
CodeIgniter application.
--B_ALT_5a7416736d6ea
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=3Ch1=3ESending email via SMTP server=3C/h1=3E=3Cp=3EThis email has sent vi=
a SMTP server from CodeIgniter application.=3C/p=3E
--B_ALT_5a7416736d6ea--
I have hidden my email id in this question for security purposes.
I find so many code examples that they wanted to change local php.ini and sendmail.ini files to send emails but I think that's not the requirement to send mail using smtp.
I also use the PHPmailer lib and it works for smtp mail, but why CodeIgniter email lib for SMTP is not working? Which PHP version is supported for this CodeIgniter SMTP settings?
Try this:-
$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "smtp";
$config['smtp_host'] = "mail.google.com";
$config['smtp_port'] = "26";
$config['smtp_user'] = "********#gmail.com";
$config['smtp_pass'] = "************";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('*********#gmail.com');
$email_body = "Sending Email from server.";
$this->email->to($userEmail']);
$this->email->subject('Email Subject');
$this->email->message($email_body);
$email = $this->email->send();
i want to send an email from my local host using code igniter. I'm using lamp here. My code shows below error
Exit status code: 127
Unable to open a socket to `Sendmail`. Please check settings.
Unable to send email using `PHP` `Sendmail`. Your server might not be configured to send mail using this method.
Date: Fri, 12 May 2017 08:01:46 +0200
From: "`jatin`"
Return-Path: <xxx>
To: xxx
Subject: =?UTF-8?Q?Hi..=20?=
Reply-To: <xxx>
User-Agent: `CodeIgniter`
X-Sender: xxx
X-Mailer: `CodeIgniter`
X-Priority: 3 (Normal)
Message-ID: <xxx>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use PHP mailer for sending mail.
using this you can send mail easily without any warning and error
Download PHP mailer from here: PHPMailer
require_once(APPPATH.'third_party/PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "test#gmail.com"; // your email address
$mail->Password = "test"; // your gmail password
$mail->SetFrom('test#gmail.com', 'Test'); //sender mail address
$mail->isHTML(true);
$mail->Subject = "Subject";
$mail->Body = 'hello there';
$destino = 'test#gmail.com'; // receiver email address
$mail->AddAddress($destino, "Receiver");
if(!$mail->Send()) {
return false;
} else {
return true;
}
You have to set access for less trusted apps in your Gmail account also:
Login to your gmail account
Click on MyAccount from Google Apps
Click on 'Signing in to Google' from left panel
And Turn on 'Allow less secure apps' from bottom of page
now try to send mail.it's works 100%.
Im trying to send an E-Mail via PHPMailer. For some Reason I dont understand the authentification fails.
I also tried different things like setting authentification to PLAIN and The Secure Method to TLS, but it doesnt seem to help.
Our Exchange has a Sending Connector, which is sending the E-Mails to our Spam Proxy, which is sending the Mails out to a Mail Server, which is encrypting the Mails with DKIM.
This is my Code:
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $settings['mailserver']; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Port = "25";
$mail->Username = $settings['mail_domain']."\\".$settings['mail_username']; // SMTP username
echo $mail->Username;
$mail->Password = $settings['mail_password']; // SMTP password
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPDebug = 2;
$mail->From = $settings['mail_sender'];
$mail->AddAddress($emp_mail); // name is optional
$mail->AddReplyTo($settings['mail_sender']);
$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Neue Datei erhalten: ".$filename." - ".$_COOKIE['settings']['firmenname'];
$mail->Body = $text;
$mail->AltBody = "Bitte laden Sie diese Email in der HTML Ansicht";
if(!$mail->Send())
{
$return_code['Code'] = 500;
$return_code['Msg'] = $mail->ErrorInfo.print_r($settings);
}else{
$return_code['Code'] = "200";
}
And this is my answer:
2016-09-26 13:39:44 SERVER -> CLIENT: 220-cpanel-1.fr-hostings.at ESMTP Exim 4.87 #1 Mon, 26 Sep 2016 15:39:44 +0200
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
2016-09-26 13:39:44 CLIENT -> SERVER: EHLO transfer.feurich.com
2016-09-26 13:39:44 SERVER -> CLIENT: 250-cpanel-1.fr-hostings.at Hello cpanel-1.fr-hostings.at [92.222.157.38]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
2016-09-26 13:39:44 CLIENT -> SERVER: STARTTLS
2016-09-26 13:39:44 SERVER -> CLIENT: 220 TLS go ahead
2016-09-26 13:39:44 CLIENT -> SERVER: EHLO transfer.feurich.com
2016-09-26 13:39:44 SERVER -> CLIENT: 250-cpanel-1.fr-hostings.at Hello cpanel-1.fr-hostings.at [92.222.157.38]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
2016-09-26 13:39:44 CLIENT -> SERVER: AUTH LOGIN
2016-09-26 13:39:44 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-09-26 13:39:44 CLIENT -> SERVER: xxx=
2016-09-26 13:39:46 SERVER -> CLIENT: 535 Incorrect authentication data
2016-09-26 13:39:46 SMTP ERROR: Username command failed: 535 Incorrect authentication data
2016-09-26 13:39:46 SMTP Error: Could not authenticate.
2016-09-26 13:39:46 CLIENT -> SERVER: QUIT
2016-09-26 13:39:46 SERVER -> CLIENT: 221 cpanel-1.fr-hostings.at closing connection
2016-09-26 13:39:46 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Any Ideas?
After some researches I found out, that this is actually a cPanel Problem! It seems that cPanel is redirecting Outgoing SMTP Connections to the own local Mail Server. This Option can be disabled in
Home »Server Configuration »Tweak Settings
In the cPanel Root Panel.
I just did not think of that, because I saw a Server responding. I just did not recognize, that it was the Own Webservers Mailserver, that was responding
I have what I think is just a really simple question but I cant seem to find the answer on google or i'm just using the wrong terms.
I'm using PHP Mailer to send emails, there's no problem with that.
My problem is on the response headers I am receiving other information. Some smtp client -> server info. That's fine and all, helps me see status of smtp but now i can't read the ajax response from the page.
Is there a way to remove the client -> server info or a way to just read the returned value of the ajax page?
2016-02-27 15:42:06 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP e1sm26974173pas.1 - gsmtp
2016-02-27 15:42:06 CLIENT -> SERVER: EHLO localhost
2016-02-27 15:42:07 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [121.54.58.240]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
2016-02-27 15:42:07 CLIENT -> SERVER: AUTH LOGIN
2016-02-27 15:42:07 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-02-27 15:42:07 CLIENT -> SERVER: aUhlbHAuc3d1QGdtYWlsLmNvbQ==
2016-02-27 15:42:07 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2016-02-27 15:42:07 CLIENT -> SERVER: aWhlbHAxMjM0
2016-02-27 15:42:08 SERVER -> CLIENT: 235 2.7.0 Accepted
2016-02-27 15:42:08 CLIENT -> SERVER:
2016-02-27 15:42:08 SERVER -> CLIENT: 250 2.1.0 OK e1sm26974173pas.1 - gsmtp
2016-02-27 15:42:08 CLIENT -> SERVER:
2016-02-27 15:42:08 SERVER -> CLIENT: 250 2.1.5 OK e1sm26974173pas.1 - gsmtp
2016-02-27 15:42:08 CLIENT -> SERVER: DATA
2016-02-27 15:42:09 SERVER -> CLIENT: 354 Go ahead e1sm26974173pas.1 - gsmtp
2016-02-27 15:42:09 CLIENT -> SERVER: Date: Sat, 27 Feb 2016 16:42:06 +0100
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: Subject: Reset password complete
2016-02-27 15:42:09 CLIENT -> SERVER: Message-ID: <fcad829908390aaf1cf72f28886ac1d5#localhost>
2016-02-27 15:42:09 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.13 (https://github.com/PHPMailer/PHPMailer)
2016-02-27 15:42:09 CLIENT -> SERVER: MIME-Version: 1.0
2016-02-27 15:42:09 CLIENT -> SERVER: Content-Type: multipart/alternative;
2016-02-27 15:42:09 CLIENT -> SERVER: boundary="b1_fcad829908390aaf1cf72f28886ac1d5"
2016-02-27 15:42:09 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: This is a multi-part message in MIME format.
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: --b1_fcad829908390aaf1cf72f28886ac1d5
2016-02-27 15:42:09 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: --b1_fcad829908390aaf1cf72f28886ac1d5
2016-02-27 15:42:09 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: --b1_fcad829908390aaf1cf72f28886ac1d5--
2016-02-27 15:42:09 CLIENT -> SERVER:
2016-02-27 15:42:09 CLIENT -> SERVER: .
2016-02-27 15:42:09 SERVER -> CLIENT: 250 2.0.0 OK 1456587732 e1sm26974173pas.1 - gsmtp
2016-02-27 15:42:09 CLIENT -> SERVER: QUIT
2016-02-27 15:42:10 SERVER -> CLIENT: 221 2.0.0 closing connection e1sm26974173pas.1 - gsmtp
1
I basically just need that "1" at the end as confirmation of ajax call.
Please help. Thank you
Wow, i found my answer as soon as i Posted it here.
Just had to remove
$mail->SMTPDebug = 2;
How silly of me. Thanks anyways!
application/config/email.php
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'tls://smtp.aol.com';
$config['smtp_user'] = 'chris.muench';
$config['smtp_pass'] = 'PASSWORD';
$config['smtp_port'] = '587';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['crlf'] = "\r\n";
?>
E-Mail Debug Statement:
The following SMTP error was encountered: 0
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:
from:
The following SMTP error was encountered:
Unable to send data: RCPT TO:
to:
The following SMTP error was encountered:
Unable to send data: DATA
data:
The following SMTP error was encountered:
Unable to send data: User-Agent: CodeIgniter Date: Fri, 9 Nov 2012 20:39:52 -0500 From: "PHP Point Of Sale, Inc" Return-Path: To: chris.muench#aol.com Subject: =?utf-8?Q?Reset_password?= Reply-To: "admin#phppointofsale.com" X-Sender: admin#phppointofsale.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <509db0685db38#phppointofsale.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_509db0685db40" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_509db0685db40 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit You have requested to reset your password, please click the link below in order to complete the password reset process Reset password --B_ALT_509db0685db40 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable You have requested to reset your password, please click the link below in o= rder to complete the password reset process
Note: I am able to send e-mail from a gmail account. What is wrong?