Link to home
Start Free TrialLog in
Avatar of StockExpert
StockExpertFlag for United States of America

asked on

Oscommerce website gives an emailing error.

I am using oscommerce on my commerce website. I am getting the following message at the point where the site send an email to a customer, like sending password to the customer. The site is on Windows 2003 with IIS 6.

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in e:\webaddress\shop\includes\classes\email.php on line 500

The related code on line 500 is: return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));

The following is the subsequent codes around line 500.

if (EMAIL_TRANSPORT == 'smtp') {
       return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));

       
       
        /*
        require_once(DIR_WS_CLASSES . "class.phpmailer.php");

            $pMail = PHPMailer();
            
            $pMail->From     = $from_addr;
            $pMail->FromName = $from_name;
                        
            $pMail->IsSMTP();
            $pMail->Host     = localhost;      // replace with your smtp server
                        
            $pMail->Subject = $subject;
            $pMail->Body    = $this->output;
            $pMail->AddAddress($to_addr, $to_name);
            $pMail->IsHTML(true);
                        
            return $pMail->Send();
            
            $pMail->ClearAddresses();
            $pMail->ClearAttachments();
            */
            
      } else {
        return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
      }
    }
 


Can someone help? Many thanks.

ASKER CERTIFIED SOLUTION
Avatar of geowrian
geowrian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StockExpert

ASKER

webserver runs virtual smtp
running on port 25
it accepts unauthorized relay

Can you explain detail: " verify the email settings from the web host and plug those values in."

Thanks.
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Changed it to the IP address of the server. it makes the error message different. now:

Warning: Cannot modify header information - headers already sent by (output started at e:\webaddress\shop\includes\classes\email.php:1) in e:\webaddress\shop\includes\functions\general.php on line 29

the line 29 in general.php isheader('Location: ' . $url);

what should i do now?

Thanks.

Here is more information around the line 29

// Redirect to another page or site
  function tep_redirect($url) {
    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);   <b>***this is line 29***** </b>

    tep_exit();
  }

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Enphyniti: I checked any white space, corrected and it still the same.

I have to change my comment above. After changing the localhost to the ip address it still generates the same error. I was using google chrole and saw this error.

Warning: mail() [function.mail]: Failed to connect to mailserver at "70.62.159.243" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in e:\webaddress\shop\includes\classes\email.php on line 500

Warning: Cannot modify header information - headers already sent by (output started at e:\webaddress\shop\includes\classes\email.php:1) in e:\webaddress\shop\includes\functions\general.php on line 29

Somehow, I changed the browser to IE and it didn't show the first error. I thought the change made the difference. I changed back to google chrome, it's now same as the original.

Any other idea? Thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
telnet definedSMTPserver 25...
it says: could not connect to the host, on port 25: connect failed

hmmm... looks like the port doesnt have the definedsmtp...
What's your host ?
check services - is smtp running?
oh... I see what you mean now... I am trying again
the ip is 70.62.159.243

can you do that for me and let me know what's going on? i am getting errors...
Looks like SMTP is not configured to accept on port 25, or a firewall may be interfering. Make sure the SMTP service is running and the port is open on any firewalls on the server.
try it again. the relay was off and it's on now. if you still think that the port is closed, let me know. the firewall was/is off. smtp service is running too.
Connexion to port 25 : OK
Connexion to mail server : Bad
the webserver sends email without problems in some asp web applications, using the smtp virtual server. the problem is only in this php website.
Connexion to mail server : Bad
how can i fix it? what is "Bad" mean?
Since your app and your mailserver are on the same system, don't use your external IP.  Use either localhost, 127.0.0.1, or the LAN ip.

I cannot connect to 70.62.159.243 on 25.  it drops the connection.
Enphyniti: can you try it again connecting to 70.62.159.243? it should work now.

i changed it to 127.0.0.1. it still the same...
this is the line 500:

 return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));

if i remove this line from the code, it goes. and leave the following error


Warning: Cannot modify header information - headers already sent by (output started at e:\www.greencash.us\shop\includes\classes\email.php:1) in e:\www.greencash.us\shop\includes\functions\general.php on line 29
Solution: I found a blank space after the end of config.php file. sigh... removing this space solved this problem. I send many thanks to experts who helped me in this question. You guys are great!
Good news! Thanks for the points! Happy new year!