bob302 Posted December 29, 2010 Share Posted December 29, 2010 I am trying to send email from localhost using my isp. not having success...below is current config. I have tried many of these and they all give me the same message about smtp, port error, etc......I have even reinstalled wampserver2 thinking I may have don something wrong.....I read the forums and still get errors. Here is my current config.... [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = rlv302@att.net <?php $to = "gypsy571@yahoo.com"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "rlv302@att.net"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> Error message received: 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\cccga\testmail.php on line 10 Mail Sent. > ANy help greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/ Share on other sites More sharing options...
trq Posted December 29, 2010 Share Posted December 29, 2010 Generally your isp will require authentication to use there smtp servers, this is not supported by php's mail function which expects a local mail server to be installed. In fact, the configuration you have shown us is still attempting to use an smtp server on localhost. Anyway, your best bet is to either install a mail server locally or to use a third party mail library like PHPMailer which can connect and authenticate to remote servers. Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/#findComment-1152430 Share on other sites More sharing options...
bob302 Posted December 29, 2010 Author Share Posted December 29, 2010 Thank you finally explained! SO where is the best place toget phpmail and a tutorial. THanks Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/#findComment-1152645 Share on other sites More sharing options...
bob302 Posted December 29, 2010 Author Share Posted December 29, 2010 well I installed phpmailer....here is scrip;t and error <?php require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.att.yahoo.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port $mail->Username = "rlv302@att.net"; // GMAIL username $mail->Password = "magyar302"; // GMAIL password $mail->From = "rlv302@att.net"; $mail->FromName = "cccga"; $mail->AddAddress("rlv302@att.net"); $mail->Subject = "Test PHPMailer Message"; $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This was sent with phpMailer_example3.php."; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } ?> error SMTP Error: Could not connect to SMTP host. Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host. Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/#findComment-1152698 Share on other sites More sharing options...
trq Posted December 29, 2010 Share Posted December 29, 2010 Looks like half of your example code must have been for connecting to GMail. GMail uses different ports. Generally, the smtp port is 25. Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/#findComment-1152774 Share on other sites More sharing options...
bob302 Posted December 30, 2010 Author Share Posted December 30, 2010 the gmail was copied from a sample script where i substituted my own info.....the port on my outlook for my m ail shows a p;ort of 465 Quote Link to comment https://forums.phpfreaks.com/topic/222864-php-email/#findComment-1152813 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.