Page 2 of 2

Posted: Wed May 19, 2010 5:41 pm
by Michbern
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.

Posted: Wed May 19, 2010 5:51 pm
by Klemen
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)?

Posted: Thu May 27, 2010 9:24 am
by lupolo
jrewolinski 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.

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>"; 
} 
and change the following lines in your sendmail.php file.

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";
Anyone knows a working fix for a no_reply email

Posted: Mon May 31, 2010 10:07 am
by lupolo
FIX:

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 */
admin_reply_ticket.php

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 */
Other files, i diddent adjust yet:
admin_submit_ticket.php
mail.php
ticket.php --> ?

Re: Working SMTP with Authentication

Posted: Mon Jan 31, 2011 7:08 am
by josea
If problems ......activate debug:

Code: Select all

$smtp->debug = false; // 
Change To:

Code: Select all

$smtp->debug = true; // 
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:

Code: Select all

 $smtpserver = "0.0.0.0"; //SMTP server IP address
To:

Code: Select all

 $smtpserver = "localhost"; //SMTP server IP address
Deactivate debug....

May be helps.... Works for me.. :D

Re: Working SMTP with Authentication

Posted: Thu Feb 03, 2011 7:04 pm
by mblevins
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.

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)
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

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; //
use this:

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']; //
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:

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);
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.

Code: Select all

@mail($tmpvar['email'],$hesklang['ticket_received'],$msg,$headers);
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:

Code: Select all

@mail($email,$hesklang['new_ticket_submitted'],$msg,$headers);
then code you add in would look like this:

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>";
    }
and if it's the first @mail line you've changed, make sure you have:

Code: Select all

required("sendmail.php");
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.

Re: Working SMTP with Authentication

Posted: Fri Feb 04, 2011 6:57 am
by lupolo
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)

Re: Working SMTP with Authentication

Posted: Fri May 06, 2011 2:54 am
by dennis00
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

Re: Working SMTP with Authentication

Posted: Fri May 06, 2011 4:58 pm
by jrewolinski
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?