mail server for local host

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bob302
Forum Newbie
Posts: 7
Joined: Sat Dec 18, 2010 7:01 pm

mail server for local host

Post by bob302 »

I am a newbie to php and local server testing environment. I have installed Wampserver without issue. I have developed some php scripts for sites and they work pretty well. Now, I am trying to send an email to a user with a code for registration much like is done on this site. However, to my chagrin and I guess embarrassment, I cannot get any of the mail server (free) working. I have tried postcast, send mail, etc. and am having no luck. Is there anyone who can tell me where I might get a good tutorial on how to get a server working or how to change php.ini to utilize my own isp. Thanks....apologize for my ignorance, but would like some advice.
Thanks.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: mail server for local host

Post by social_experiment »

Google search results
Take a look at some of these, hth.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
bob302
Forum Newbie
Posts: 7
Joined: Sat Dec 18, 2010 7:01 pm

Re: mail server for local host

Post by bob302 »

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
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: mail server for local host

Post by Celauran »

bob302 wrote:Here is my current config....
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
Do you have a mail server running locally? For testing purposes, you could always use your ISP's SMTP server, or gmail's or whatever.
bob302
Forum Newbie
Posts: 7
Joined: Sat Dec 18, 2010 7:01 pm

Re: mail server for local host

Post by bob302 »

I do not have a mail server running locally. Tried to intall many of the free ones and was never able to send mail. I am a newbie in that area and could not find one with a tut or instructions. I have tried to use my own ISP as indicated above and received the above errors. Are you aware of a tutorial or how to reconfig ini and what code to include in the script? Thanks so much for looking.
Bob
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: mail server for local host

Post by Celauran »

bob302 wrote:I have tried to use my own ISP as indicated above and received the above errors.
I don't see any examples above that use your ISP, only the one attempting to use a locally installed mail server. Have you tried setting SMTP = smtp.yourisp.com? What errors did that produce? Did you try changing the SMTP port to 587? Any luck with that?
bob302
Forum Newbie
Posts: 7
Joined: Sat Dec 18, 2010 7:01 pm

Re: mail server for local host

Post by bob302 »

tried this.......
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.att.yahoo.com
; 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.";
?>

Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.att.yahoo.com" 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. >

will change port and try again
bob302
Forum Newbie
Posts: 7
Joined: Sat Dec 18, 2010 7:01 pm

Re: mail server for local host

Post by bob302 »

interesting simply changed the port to 587 in ini - stopped and restarted wamp2 and I get the same error message indicating port 25.....
Post Reply