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
Related
I am getting the following error while trying to send email using nodemailer and office365 account:
Error: Invalid login: 535 5.7.3 Authentication unsuccessful [MAXPR01CA0095.INDPRD01.PROD.OUTLOOK.COM]
My nodemailer configuration is as below:
const mailTransport = nodemailer.createTransport({
host: smtp.office365.com ,
port: 587,
requireTLS: true,
tls: { ciphers: 'SSLv3' },
auth: {
user: user.email#email.com,
pass: *****,
},
});
In Microsoft admin center, I have enabled SMPTP AUTH and also disabled two factor authentication.
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%.
I have a problem with PHPMailer inside my Windows Server 2012. I'm using XAMPP as my local server. I notice that i cannot ping smtp.gmail.com in my window server 2012. it says
ping request could not find host smtp.gmail.com. Please check and try again
I added this line in php.ini
[mail function]
smtp_server=smtp.gmail.com
smtp_port=25
sendmail_path ="\"D:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On
And I added this line in sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=example#gmail.com
auth_password=password
force_sender=
force_recipient=
hostname=localhost
I test my PHPMailer in my local PC, it works fine. I can send into my own domain email ("example#pn.com") and other domain email such as test#gmail.com, test#yahoo.com etc. Here's my PHPMailer code.
testsend.php
<?php
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "example#gmail.com";
$mail->Password = "password";
$mail->setFrom('test#gmail.com', 'First Last');
//$mail->addReplyTo('replyto#example.com', 'First Last');
$mail->addAddress('test#gmail.com', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->Body = 'dfssf';
$mail->AltBody = 'This is a plain-text message body';
//$mail->addAttachment('images/phpmailer_mini.png');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
But when I add similar PHPMailer folder and files inside my server, it only work when I send to my own domain which is ("example#pn.com").It does not work with other email domain such as gmail, yahoo etc. It says
Mailer Error: SMTP Error: The following recipients failed: test#gmail.com: Unable to relay
How to fix that problem ?
Thanks.
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!
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();