Working SMTP with Authentication
Moderator: mkoch227
Hi I have this Error
Trying to mail.tacfitcommando.com:26 220-rmax.hostspectrum.com ESMTP Exim 4.69 #1 Wed, 19 May 2010 10:39:00 -0700 Connected to relay host mail.tacfitcommando.com > HELO localhost 220-We do not authorize the use of this system to transport unsolicited, > AUTH LOGIN USERNAMEBASE64= 220 and/or bulk e-mail. > PASSWORDBASE64 250 rmax.hostspectrum.com Hello localhost [64.92.105.3] > MAIL FROM:<> 503 AUTH command used when not advertised Error: Remote host returned "503 AUTH command used when not advertised" Error: Error occurred while sending MAIL FROM command. Error: Cannot send email to Disconnected from remote host
Anyway know what this means? I tried having the value of $smtpusermail= ""; still doesn't work.
Trying to mail.tacfitcommando.com:26 220-rmax.hostspectrum.com ESMTP Exim 4.69 #1 Wed, 19 May 2010 10:39:00 -0700 Connected to relay host mail.tacfitcommando.com > HELO localhost 220-We do not authorize the use of this system to transport unsolicited, > AUTH LOGIN USERNAMEBASE64= 220 and/or bulk e-mail. > PASSWORDBASE64 250 rmax.hostspectrum.com Hello localhost [64.92.105.3] > MAIL FROM:<> 503 AUTH command used when not advertised Error: Remote host returned "503 AUTH command used when not advertised" Error: Error occurred while sending MAIL FROM command. Error: Cannot send email to Disconnected from remote host
Anyway know what this means? I tried having the value of $smtpusermail= ""; still doesn't work.
This might be a long shot, but do you have sendmail_from set to an e-mail address in your php.ini file (even though it's a Windows server and you use SMTP)?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Anyone knows a working fix for a no_reply emailjrewolinski wrote:If I understand correctly... you could probably do this... Not sure if it'll work though, as I said, I'm not great with coding. There's already a built in "additional_headers" variable in the existing code, but I'm not sure about its format, so I added 2 additional header fields to the sendmail.php file.
and change the following lines in your sendmail.php file.Code: Select all
require("sendmail.php"); ########################################## $smtpserver = "0.0.0.0"; //SMTP server IP address $smtpserverport =25; //SMTP port $smtpusermail = $hesk_settings[noreply_mail]; //SMTP email $smtpemailto = $orig_email; // $smtpuser = "username"; //SMTP username $smtppass = "password"; //SMTP password $mailsubject = $hesklang['new_reply_staff']; //subject $mailbody = $msg; //body $mailtype = "TXT"; // $mailreply = $hesk_settings[noreply_mail]; //ADD THIS LINE $mailreturn = $hesk_settings[webmaster_mail]; //ADD THIS LINE ########################################## $smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass); //true $smtp->debug = false; // if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype, "", "", "", $mailreply, $mailreturn)) { //echo "send successfully!!!<br>"; } else { //echo "send unsuccessfully!!!!<br>"; }
Code: Select all
function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "", $hesk1 = "", $hesk2 = "") //ADD THE LAST 2 VARIABLES
Code: Select all
$header.= "From: $from<".$from.">\r\n"; $header.= "Subject: ".$subject."\r\n"; $header.= "Reply-to: "$hesk1"\r\n"; //ADD THIS LINE $header.= "Return-Path: "$hesk2"\r\n"; //ADD THIS LINE $header.= $additional_headers; $header.= "Date: ".date("r")."\r\n"; $header.= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
FIX:
submit_ticket.php
admin_reply_ticket.php
Other files, i diddent adjust yet:
admin_submit_ticket.php
mail.php
ticket.php --> ?
submit_ticket.php
Code: Select all
/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
/*@mail($email,$hesklang['ticket_received'],$msg,$headers);*/
require("sendmail.php");
##########################################
$smtpserver = "smtpout.asthosting.nl"; //SMTP server IP address
$smtpserverport =25; //SMTP port (I had to use alternate port)
$smtpemailto = $email; //
$smtpuser = ""; //SMTP username for authentication
$smtppass = ""; //SMTP password for authentication
$mailsubject = $hesklang['ticket_received']; //subject
$mailbody = $msg; //body
$mailtype = "TXT"; //
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//true
$smtp->debug = false; //
/* if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype)) */
if($smtp->sendmail($smtpemailto, $hesk_settings[noreply_mail], $mailsubject, $mailbody, $mailtype))
{
//echo "send successfully!!!<br>";
}
else
{
//echo "send unsuccessfully!!!!<br>";
}
/* Need to notify any admins? */
Code: Select all
/* Send e-mail to staff */
$email=implode(',',$admins);
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
/*@mail($email,$hesklang['new_ticket_submitted'],$msg,$headers);*/
##########################################
$smtpserver = "smtpout.asthosting.nl"; //SMTP server IP address
$smtpserverport =25; //SMTP port
$smtpuser = ""; //SMTP username
$smtppass = ""; //SMTP password
$mailsubject = $hesklang['new_ticket_submitted']; //subject
$mailbody = $msg; //body
$mailtype = "TXT"; //
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//true
$smtp->debug = false; //
/* if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype)) */
if($smtp->sendmail($hesk_settings['support_mail'], $hesk_settings['noreply_mail'], $mailsubject, $mailbody, $mailtype))
{
//echo "send successfully!!!<br>";
}
else
{
//echo "send unsuccessfully!!!!<br>";
}
}
/* Next ticket show suggested articles again */
Code: Select all
/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Bcc: software@ace-europe.nl'\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
/*@mail($ticket['email'],$hesklang['new_reply_staff'],$msg,$headers);*/
require("sendmail.php");
##########################################
$smtpserver = "smtpout.asthosting.nl"; //SMTP server IP address
$smtpserverport =25; //SMTP port
$smtpemailto = $ticket['email']; //
$smtpuser = ""; //SMTP username
$smtppass = ""; //SMTP password
$mailsubject = $esubject; //subject
$mailbody = $msg; //body
$mailtype = "TXT"; //
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//true
$smtp->debug = false; //
/* if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype)) */
/* if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype, $headers))*/
if($smtp->sendmail($smtpemailto, $hesk_settings[noreply_mail], $mailsubject, $mailbody, $mailtype))
{
//echo "send successfully!!!<br>";
}
else
{
//echo "send unsuccessfully!!!!<br>";
}
/* Set reply submitted message */
admin_submit_ticket.php
mail.php
ticket.php --> ?
Re: Working SMTP with Authentication
If problems ......activate debug:
Change To:
After activate debug try again
If you see this error:
SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
Change:
To:
Deactivate debug....
May be helps.... Works for me..
Code: Select all
$smtp->debug = false; //
Code: Select all
$smtp->debug = true; //
If you see this error:
SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
Change:
Code: Select all
$smtpserver = "0.0.0.0"; //SMTP server IP address
Code: Select all
$smtpserver = "localhost"; //SMTP server IP address
May be helps.... Works for me..

Re: Working SMTP with Authentication
Ok, I was getting the white screen when logging in as well. I use email for my server through google apps. I have my normal staff email accounts through there as well as the noreply account "alerts@mydomain.com". Everything works as you would expect it to. This was done on an Ubuntu 11.04 server with PHPv5.3.5 built from source.
To get it working here's the code I changed.
That was to get it to login and authenticate for sending emails out through the google custom domain.
Obviously if you don't use google apps for email you'll change it to your server. And the "require("sendmail.php");" only goes on the first time you comment out the @mail code. After that it's automatically included. I also put sendmail.php in the admin directory, though I'm not sure that is required.
then in the admin_submit_ticket.php instead of
use this:
notice here in the $smtpusermail line it's actually $tmpvar['email']; rather than $email as the $email has not yet been created and isn't used for ticket received call.
In admin_reply_ticket.php use this code:
notice again that it's not $email or $orig_email for the $smtpmailto variable.
If you're unsure of what to put for $smtpemailto look at the original line, here is an example of what I'm talking about.
So if that's the line you commented out, the $smtpemailto = "" would be $smtpemailto = "$tmpvar['email'];
Also, I recommend to comment every instance of @mail line and replace with the code, look at the original @mail line and if it was $hesklang['new_reply_staff']; use as $mailsubject $mailsubject = $hesklang['new_reply_staff]; here's another example:
if the @mail line you commented out was this:
then code you add in would look like this:
and if it's the first @mail line you've changed, make sure you have:
after the /* @mail */
I hope it's clear, if not feel free to ask me for help. Thanks to the OP for such a wonderful script, and to Klemen for the Hesk script.
To get it working here's the code I changed.
Code: Select all
require("sendmail.php");
##########################################
$smtpserver = "ssl://smtp.gmail.com"; //SMTP server IP address
$smtpserverport =465; //SMTP port (I had to use alternate port)
Obviously if you don't use google apps for email you'll change it to your server. And the "require("sendmail.php");" only goes on the first time you comment out the @mail code. After that it's automatically included. I also put sendmail.php in the admin directory, though I'm not sure that is required.
then in the admin_submit_ticket.php instead of
Code: Select all
require("sendmail.php");
##########################################
$smtpserver = "ssl://smtp.gmail.com"; //SMTP server IP address
$smtpserverport =465; //SMTP port
$smtpusermail = "yourfullemailaddress"; //SMTP email
$smtpemailto = $email; //
Code: Select all
/* @mail($tmpvar['email'],$hesklang['ticket_received'],$msg,$headers);*/
require("sendmail.php");
##########################################
$smtpserver = "ssl://smtp.gmail.com"; //SMTP server IP address
$smtpserverport =465; //SMTP port
$smtpusermail = "yourfullemailaddress"; //SMTP email
$smtpemailto = $tmpvar['email']; //
In admin_reply_ticket.php use this code:
Code: Select all
/*@mail($ticket['email'],$hesklang['new_reply_staff'],$msg,$headers);*/
require("sendmail.php");
##########################################
$smtpserver = "ssl://smtp.gmail.com"; //SMTP server IP address
$smtpserverport =465; //SMTP port
$smtpusermail = "yourfullemailaddress"; //SMTP email
$smtpemailto = $ticket['email']; //
$smtpuser = "yourfullemailaddress"; //SMTP username
$smtppass = "passwordforyouraccount"; //SMTP password
$mailsubject = $hesklang['new_reply_staff']; //subject
$mailbody = $msg; //body
$mailtype = "TXT"; //
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
If you're unsure of what to put for $smtpemailto look at the original line, here is an example of what I'm talking about.
Code: Select all
@mail($tmpvar['email'],$hesklang['ticket_received'],$msg,$headers);
Also, I recommend to comment every instance of @mail line and replace with the code, look at the original @mail line and if it was $hesklang['new_reply_staff']; use as $mailsubject $mailsubject = $hesklang['new_reply_staff]; here's another example:
if the @mail line you commented out was this:
Code: Select all
@mail($email,$hesklang['new_ticket_submitted'],$msg,$headers);
Code: Select all
/*@mail($ticket['email'],$hesklang['new_ticket_submitted'],$msg,$headers);*/
require("sendmail.php");
##########################################
$smtpserver = "ssl://smtp.gmail.com"; //SMTP server IP address
$smtpserverport =465; //SMTP port
$smtpusermail = "yourfullemailaddress"; //SMTP email
$smtpemailto = $ticket['email']; //
$smtpuser = "yourfullemailaddress"; //SMTP username
$smtppass = "passwordforyouraccount"; //SMTP password
$mailsubject = $hesklang['new_ticket_submitted']; //subject
$mailbody = $msg; //body
$mailtype = "TXT"; //
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//true
$smtp->debug = false; //
if($smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype))
{
//echo "send successfully!!!<br>";
}
else
{
//echo "send unsuccessfully!!!!<br>";
}
Code: Select all
required("sendmail.php");
I hope it's clear, if not feel free to ask me for help. Thanks to the OP for such a wonderful script, and to Klemen for the Hesk script.
Re: Working SMTP with Authentication
The only thing iám stil looking for is how i can do the following:
- email from
- email from name
- email back wenn failure (email adres doesent exist)
for example:
- email from (no-reply@mydomail.com)
- email from name (Helpdesk Supporter)
- email back wenn failure (email adres doesent exist) (helpdesk@mydomail.com)
- email from
- email from name
- email back wenn failure (email adres doesent exist)
for example:
- email from (no-reply@mydomail.com)
- email from name (Helpdesk Supporter)
- email back wenn failure (email adres doesent exist) (helpdesk@mydomail.com)
Re: Working SMTP with Authentication
Hi, I got the error message as following~
Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host
Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host Trying to mail.hwazone.com.tw:25 220 hzsvr.hwazone.com.tw Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Fri, 6 May 2011 10:32:59 +0800 Connected to relay host mail.hwazone.com.tw > HELO localhost 250 hzsvr.hwazone.com.tw Hello [192.168.11.9] > AUTH LOGIN aHdhem9uZQ== 503 5.5.2 Send hello first. Error: Remote host returned "503 5.5.2 Send hello first." Error: Error occurred while sending HELO command. Error: Cannot send email to Disconnected from remote host
-
- Posts: 8
- Joined: Tue Aug 04, 2009 6:01 pm
Re: Working SMTP with Authentication
Just guessing here, but it looks like it doesn't like the "localhost" name. Did you set that in the script somewhere? Maybe try using the fully qualified domain name instead. If this is a linux server, is the hostname set on the server to a FQDN?