Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Failed to connect to mailserver


Guest

Recommended Posts

Hi, I have read numerous mails about this, but still get the following error message when trying to send an email:

 

PHP 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 D:hshomesonicstasonicstars.comadminincludesclassesemail.php on line 460 PHP Warning: Cannot modify header information - headers already sent in D:hshomesonicstasonicstars.comadminincludesfunctionsgeneral.php on line 18

 

I have set the email options to SMTP and the linefeeds to CRLF. I've also checked the email.php file for whitespace.

 

I cannot access the php.ini file, but my webhosting company suggested that I "edit my mail function".

 

I've been struggling with this for hours now, and would really appreciate any help!

 

thanks

 

Chris Thomas

Link to comment
Share on other sites

Are you (or your ISP) running an email server on your localhost? If not, it will not work with your current settings. PHP.ini will have to be modified to include a working SMTP server. You might be able to do this just for your site through ini_set. You will probably have to use the smtp with authentication contribution to get it working with an external mail server.

 

Good luck,

Matt

Link to comment
Share on other sites

Hi,

 

thanks for your response. When I check server info in admin smtp is set to localhost, port 25.

 

My ISP says I do not need to edit my php.ini file. Instead they suggested the following:

You just have to edit your mail() function.

 

Any PHP page that uses the mail() function should use the mail function with a sendmail flag. For example, a mail() function that is normally used like this:

 

mail( $mailto, $mailsubj, $mailmsg, $mailheader );

 

should in fact be used like this:

 

mail( $mailto, $mailsubj, $mailmsg, $mailheader, "[email protected]");

 

Note the sendmail flag at the end of the function "-f" followed by the e-mail address mail is sending from.

Does this mean I just need to edit the code in email.php?

thanks for any help you can offer.

 

Chris

Link to comment
Share on other sites

Sorry, I missed seeing this. If you are running MS Windows (on the server), then your ISP is all wet. You can't use the sendmail flag, because SMTP does not support that. On a MS Windows server, all the mail configuration is done in php.ini. It won't accept the sendmail flags. You will have to change the php.ini to point to a valid SMTP server or set it in .htaccess or with ini_set. Or use the SMTP w/ Authentication contribution link posted previously.

 

Good luck,

Matt

Link to comment
Share on other sites

thanks. The following code fixed it for me

 

ini_set(SMTP, "mail.sonicstars.com");

 

to this file:

 

catalogincludesclassesemail.php

 

thanks for your help

 

Chris

Link to comment
Share on other sites

Hey there, I have been having the same problem configuring the STMP on my local machine. I am wondering how you used that code up above to fix your problem, sonicstars, because I can't find ini_set in email.php or in php.ini.

 

Thank you,

Chris

Link to comment
Share on other sites

ini_set sets a configuration value in the local PHP code, rather than in php.ini. AFAIK, you can put this anywhere before the mail call (make sure that it isn't inside an if or other conditional). At the top of the code in email.php would be fine.

 

Good luck,

Matt

Link to comment
Share on other sites

Hello Matt. Hello Chris

 

 

My shopping cart MS 2.1 was working well.

 

Of recent I noticed that it has stopped sending E mail

for customer registration and order confirmation.

 

I have checked the admin E mail options and

verified that the E mail send is set TRUE

 

I have also checked that the MANUAL e mail

send function is working so the SERVER seems to be

sending out mail.

 

My host has confirmed that the server is not WINDOWS

and my mail was working well with the SENDMAIL option

with a FROM address external ([email protected])

 

I tried to set the sendmail flag as suggested by the ISP

in one of the above post but can't locate a identical function call

in email.php

 

My ISP suggested to change the FROM address to one on the

hosting server which I did ( [email protected]) without

any result.

 

As you can see this is a pretty aweful situation as I can't receive

any credit card info practically rendering the OCS cart USELESS despite

all good features.

 

I have been posting this problem for TWO weeks now for the

attention of the developpers but no one seems to know what to do

about it.

 

Can anyone please suggest what might be the problem ?

 

Many thanks in advance

Link to comment
Share on other sites

  • 5 months later...
thanks. The following code fixed it for me

 

ini_set(SMTP, "mail.sonicstars.com");

 

to this file:

 

catalogincludesclassesemail.php

 

thanks for your help

 

Chris

What line do you put this in?

Link to comment
Share on other sites

thanks. The following code fixed it for me

 

ini_set(SMTP, "mail.sonicstars.com");

 

to this file:

 

catalogincludesclassesemail.php

 

thanks for your help

 

Chris

What line do you put this in?

Got it. Line 500. :D Thanks. This solved a major headache for me!!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...