co.ador Posted January 5, 2010 Share Posted January 5, 2010 I got this warning after using the mail function. It seem not to be configure at the php.ini does anybody has any idea on how to fix it. 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 C:\wamp\www\step2.php on line 14 Help please... Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/ Share on other sites More sharing options...
Kaboom Posted January 5, 2010 Share Posted January 5, 2010 you have it set as: mail("[email protected]", "Subject", "Message here", "Visitors email here"); right? If not set as that, if you do the mail function may be inactive on your server Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988657 Share on other sites More sharing options...
co.ador Posted January 5, 2010 Author Share Posted January 5, 2010 I have set exactly like that just as below mail('[email protected]', 'Contact us Message', $text, 'From: '.$name.' <'. $email.'>'); Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988658 Share on other sites More sharing options...
trq Posted January 5, 2010 Share Posted January 5, 2010 Do you have a mail server setup on localhost? Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988659 Share on other sites More sharing options...
co.ador Posted January 5, 2010 Author Share Posted January 5, 2010 this is how the mail function is configure at php.ini [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = you@yourdomain ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988660 Share on other sites More sharing options...
co.ador Posted January 5, 2010 Author Share Posted January 5, 2010 I don't know thorpe how can I find out the mail server set up on localhost? Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988661 Share on other sites More sharing options...
oni-kun Posted January 5, 2010 Share Posted January 5, 2010 I don't know thorpe how can I find out the mail server set up on localhost? WAMP = Windows Apache MySQL & PHP, To my knowledge an SMTP server would not be installed along with it. You'd need to install it separately or use a paid hosting's account. EDIT: If you really wanted to find out if you had it or not, Go into command line and type "telnet 127.0.0.1 25", and if it does not connect there's nothing accepting the SMTP port. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988662 Share on other sites More sharing options...
Deoctor Posted January 5, 2010 Share Posted January 5, 2010 check this out in the command prompt telnet localhost 25. if it connecting then it should workkk.. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988663 Share on other sites More sharing options...
trq Posted January 5, 2010 Share Posted January 5, 2010 If your not sure you haver a mail server installed you likely don't. Is this your dev box? Or a hosted server? Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988753 Share on other sites More sharing options...
teamatomic Posted January 5, 2010 Share Posted January 5, 2010 On the SMTP line put in the mailserver of your ISP, something like mail.ISP.net Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988779 Share on other sites More sharing options...
co.ador Posted January 5, 2010 Author Share Posted January 5, 2010 @ thorpe that was the localhost but i have a hosted server as well. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988850 Share on other sites More sharing options...
co.ador Posted January 5, 2010 Author Share Posted January 5, 2010 I am getting the same error still, Can't get to configure the DNS server in my localhost. using this in the script to configure my php.ini <?php //set SMTP in php.ini ini_set("SMTP", "smtp.gmail.com");?> The php.ini configuration is [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = mail.stores.com but it is bringing a warning Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.gmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\step2.php on line 19 Can ask my host provider for the DNS server, or am I missing something else in the code? I have used the toturial below and he talks about getting an DNS server, or ISP but I don't know where to find those tools to make it work. I have asked my domain host server and they give me mail.domainname.com as the DNS server but that's what I need for this purpose? http://www.youtube.com/watch?v=xHbiPDSX9so&feature=related Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-988917 Share on other sites More sharing options...
trq Posted January 5, 2010 Share Posted January 5, 2010 A DNS server is a 'domain name server', not at all what you need. Easiest way to use gmail as your mail server on a local box (providing it is a Linux box) is to install and configure ssmtp. ssmtp will emulate sendmail and allow you to use remote smtp servers (like gmail provide). Otherwise, you might want to look into using a mail class like PHPMailer as php's default mail() function has not way of sending authentication which is usually required by remote mail servers. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989209 Share on other sites More sharing options...
hectork Posted January 6, 2010 Share Posted January 6, 2010 one of the easiest way to send mail is to download PHP Mailer and then ...this file will be able to send the mail..... place this file in the phpmailer folder and wen this file is executed,u will be able to send the mail <? //require("phpmailer/class.phpmailer.php"); include("class.phpmailer.php"); include("class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP //IsSMTP(); // send via SMTP $mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server $mail->Port = 465; // set the port to use $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "[email protected]"; // SMTP username $mail->Password = "password"; // SMTP password $webmaster_email = "[email protected]"; //Reply to this email ID $email="recipientsmailid"; // Recipients email ID $name="recipients name"; // Recipient's name $mail->From = $webmaster_email; $mail->FromName = "Webmaster"; $mail->AddAddress($email,$name); $mail->AddReplyTo($webmaster_email,"Webmaster"); $mail->WordWrap = 50; // set word wrap //;$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //;$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment $mail->IsHTML(true); // send as HTML $mail->Subject = "This is the subject"; $mail->Body = "Hi, This is the HTML BODY "; //HTML Body $mail->AltBody = "This is the body when user views in plain text format"; //Text Body if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989337 Share on other sites More sharing options...
teamatomic Posted January 6, 2010 Share Posted January 6, 2010 in the ini file or set ini to port 465 for gmail HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989400 Share on other sites More sharing options...
co.ador Posted January 6, 2010 Author Share Posted January 6, 2010 Can see why it was not working the port was 25 and in this case is 465. Ok Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989458 Share on other sites More sharing options...
trq Posted January 6, 2010 Share Posted January 6, 2010 Can see why it was not working the port was 25 and in this case is 465. Ok Is that a question? Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989469 Share on other sites More sharing options...
co.ador Posted January 6, 2010 Author Share Posted January 6, 2010 that's a statement based on the to previous post. my php.ini is configure in port 25 and it was not working. Even though i have change it. I was trying to use a google dns server but having the port on 25 and not realizing i had to set it to 465. I have also realize that in the local host some extra work is needed in the php.ini but no in the host server which a configuration of php.ini is not needed. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989471 Share on other sites More sharing options...
trq Posted January 6, 2010 Share Posted January 6, 2010 You keep mentioning DNS servers. DNS servers resolve domain names, they do not send email. Gmail requires an authenticated user in order to send email so simply changing ports and pointing to Gmail is not sufficient. See my post here. Quote Link to comment https://forums.phpfreaks.com/topic/187217-mail-function-is-not-going-through/#findComment-989475 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.