Tominabox Posted June 22, 2009 Share Posted June 22, 2009 I host several websites on aplus.net. Everything with my php contact form used to work great, people would fill in their information to my form, click submit, and I would get an email. Now it doesn't work. I've been told it's because I am not properly specifying the host and port for the email to be sent through. I don't specify it at all, which I guess is the problem. I presume that aplus has taken my website and put it on a different server than the mail server, and when they did this, the disconnect has caused problems. How do I specify the port and host? Here's the specific error message I get: Warning: mail() [function.mail]: Failed to connect to mailserver at "maxima12.abac.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\inetpub\virtual\cheaptoilettank\WWWROOT\contact.php on line 45 Warning: Cannot modify header information - headers already sent by (output started at D:\inetpub\virtual\cheaptoilettank\WWWROOT\contact.php:45) in D:\inetpub\virtual\cheaptoilettank\WWWROOT\contact.php on line 47 And here's my php code that I use: <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $you = $_REQUEST['you'] ; $confirmemail = $_REQUEST['confirmemail'] ; $phone = $_REQUEST['phone'] ; $zip = $_REQUEST['zip'] ; $brand = $_REQUEST['brand'] ; $model = $_REQUEST['model'] ; $color = $_REQUEST['color'] ; $ob_Port = 587; $ob_Server = "pro54.abac.com"; if (!isset($_REQUEST['email'])) { header( "Location: http://www.cheaptoilettanklids.com/contact.html" ); } elseif (empty($email) || empty($zip)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" ); ?> <html> <head><title>Error</title></head> <body> <h1>Error</h1> <p> Oops, it appears you forgot to enter either your email address or your zip code. Please press the BACK button in your browser and try again. </p> </body> </html> <?php } else { mail( "sales@cheaptoilettanklids.com", "Request for Toilet Tank Lid from $you","$you\n $phone\n $confirmemail\n Zip Code $zip\n Brand $brand\n Model $model\n Color $color\n Comments: $message", "From: $you <$email>" ); header( "Location: http://www.cheaptoilettanklids.com/thanks.html" ); } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 I presume Don't presume or assume anything, ask them! And how would anyone on a programming forum know what your web host changed anyway? Either php or your mail server were changed so that the SMTP settings that php is using no longer work. This could also be a temporary problem with the mail server. In any case, you should be asking your host, not a programming forum. Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 22, 2009 Author Share Posted June 22, 2009 The guys at aplus.net are generally from Russia or some eastern bloc country and don't communicate well. I have never had luck having those guys give me accurate information, and when I ask for changes, it typically causes problems. The only reason I stick with them is because 99% of the time everything is great. I'm here because I'm hoping someone who knows more about programming than me can guide me to the correct way to specify the host and port on my php so the email gets sent properly. Quote Link to comment Share on other sites More sharing options...
ldougherty Posted June 22, 2009 Share Posted June 22, 2009 From this error message.. Warning: mail() [function.mail]: Failed to connect to mailserver at "maxima12.abac.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\inetpub\virtual\cheaptoilettank\WWWROOT\contact.php on line 4 In your php.ini you are specifying the mailserver SMTP as maxima12.abac.com and port SMTP_PORT as 25. This connection no longer works and needs to be adjusted to a valid SMTP server. Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 22, 2009 Author Share Posted June 22, 2009 Regarding adjusting the php.ini file, everything I've read points to that, but I'm not sure how *I* can adjust it if it is not my PC that the website is hosted on. Do hosts typically make adjustments to php.ini files at users requests? I've not had that kind of success with aplus.net when I requested before, but maybe I wasn't persistent enough. Quote Link to comment Share on other sites More sharing options...
ldougherty Posted June 22, 2009 Share Posted June 22, 2009 Well honestly that depends on the host and the change you are requesting. There really is no reason for the host to now allow a change to SMTP settings for the php.ini assuming the php.ini is your sites php.ini not the server php.ini itself Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 22, 2009 Author Share Posted June 22, 2009 This shows my naivete...you can have a php.ini for the host and one for the site? Can you tell me more about this? Does the one for my site just add to whatever is included in the host one, and if there are differences (such as the host and port info) it defaults to the site php.ini file instead of the host's file? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2009 Share Posted June 22, 2009 You can set the two smtp settings anywhere - PHP_INI_ALL. Which means - in the master php.ini, httpd.conf (Apache server), .htaccess file (when php is running as an Apache Module), local php.ini (when php is running as a CGI application), or in your script using an ini_set() statement, but until you know what caused the problem or what value they need to be set to, you are wasting your time. Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 23, 2009 Author Share Posted June 23, 2009 Ok, I've gotten further. I now have learned about using ini_set, and added: ini_set("SMTP", "xxx.abac.com"); ini_set("smtp_port", yyy); where the x's and y's are the correct values, but I get this error message: SMTP server response: 530 5.7.0 Authentication required The guy at aplus.net said that SSL is enabled, but I don't know how to modify my code to account for that. Any suggestions? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 23, 2009 Share Posted June 23, 2009 The error message means that they have changed the mail server to require SMTP Authentication. They may have in fact also switched to using a https/SSL connection, but that is secondary to and not the cause of the error message. In order to use SMTP Authentication you will need to use one of the php mailer classes instead of the php mail() function - http://swiftmailer.org/ http://phpmailer.codeworxtech.com/ If your host is making this kind of change, hopefully they have provided information in their FAQ section on what you need to do differently. Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 23, 2009 Author Share Posted June 23, 2009 These "mailer classes" you mention seem more like products than coding. So it's not possible for me to write my own code to do what I want, which is to have a form on my website where people can submit information via the form, click submit, and it sends me an email? I have to use someone's third party product and modify it to work with my settings? Quote Link to comment Share on other sites More sharing options...
947740 Posted June 23, 2009 Share Posted June 23, 2009 These "mailer classes" you mention seem more like products than coding. So it's not possible for me to write my own code to do what I want, which is to have a form on my website where people can submit information via the form, click submit, and it sends me an email? I have to use someone's third party product and modify it to work with my settings? Sure, you could reinvent the wheel. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 23, 2009 Share Posted June 23, 2009 use one of the php mailer classes instead of the php mail() function The two classes are PHP OOP (Object Oriented Programming) classes. And as already stated, you use them instead of the php mail() function (which does not support SMTP Authentication.) Reading the examples in the documentation at the posted links would have shown you how they are used in your script. Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 23, 2009 Author Share Posted June 23, 2009 Ok, so I'm feeling a little more comfortable with using one of these things, and I'm taking phpmailer-fe for a test drive. I get the following error: Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not in a.b.c.d form in D:\inetpub\virtual\cheaptoilettank\WWWROOT\testform\_lib\phpmailer-fe.php on line 166 Here's what I have on that line: $remoteaddr = $_SERVER['66.xxx.xx.55']; (where x's are the correct values) I must be configuring this wrong, can someone guide me to put this in correctly? Quote Link to comment Share on other sites More sharing options...
Tominabox Posted June 23, 2009 Author Share Posted June 23, 2009 Alright, more baby steps, I now have it set to: $remoteaddr = '66.xxx.xx.55'; $http_via = getenv('0'); $http_forwarded = getenv('0'); $remoteport = 'yyy'; But it doesn't seem to want to work. Here's my test form, if anyone cares to take a look and see why it might be hanging: http://cheaptoilettanklids.com/testform/form.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.