aspose file tools*
The moose likes PHP and the fly likes mail() is not working inn PHP script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "mail() is not working inn PHP script" Watch "mail() is not working inn PHP script" New topic
Author

mail() is not working inn PHP script

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 374
I am using following code with phpTest1.php script




When I execute this code, message is not getting sent to mymail_nirjari@yahoo.com and I get following message.
led 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\phpTest1.php on line 12

Why is that ? I dont unerstand this message.How can I use mail() in the script ?

Below is httpd.conf file
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

Let's examine the error messages:

connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini


PHP is attempting to connect to an email server on localhost (connect to mailserver at "localhost") using the standard email port (port 25).

So let me ask this: are you running an email server on your PC? I suspect that the answer is no.

The error message then gives you a hint as to what to do (verify your "SMTP" and "smtp_port" setting in php.ini).

So here is what you need to do. Find out, from your email provider, what their SMTP host name is and what port they use and then update your php.ini file to reflect that information. Since you are sending email to a yahoo address, I will assume that you are using yahoo as the email server. A search for yahoo smtp configuration yielded several results, such as this one: http://answers.yahoo.com/question/index?qid=20080814033844AA3xxOp

If you need more help, tell me which email provider you use. You should also look for the php.ini file (if you run the info.php file I suggested on your other post it will tell you where php.ini is located on your PC)
nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 374
I am learning this PHP and I am using Bell Canada as my ISP. Will they provide SMTP host name ? when I was trying to setup outlook, I was asked similar question and if I use yahoo account they would charge me for that. But google account was free. So is this similar situation ? Can I use gmail account for this ?

Thanks
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

If Bell Canada provided you with information to hook up Outlook, you can use that same information in the php.ini file to connect to them. Just look in Outlook under Account Settings for your account information.

And yes you can also connect to gmail. Here is the page on that info: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mail() is not working inn PHP script