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!
I'm trying to create a mail form in php but when I try to send an email to the recipient email address, it does not go through. I tried using an example from http://www.w3schools.com but it does not work. Here is the code.
I realize the mistake in the code above and what I forgot to add was an else statement so instead of it just saying "Thank you for using our mail form", it would have given an error message to say the email was not sent. I still can't get this mail form working. I tried this code and it says "Mail send failure - message not sent ". I uploaded the script on the web hosting service I am using and executed it. Here's the link - http://phpworks.uuuq.com/mailform4.php
Is there a difference between "user@domain.com" and "email@domain.com" or are they both the same as in putting email addresses for "$to" and "$from", from the article link you provided me with?
I have figured the problem as to why the email is not being sent as I did not configure a php.ini script with smtp server configuration. I have looked at some forums and tutorials but still confused. I would appreciate if anyone could show me a simple way of doing this so that it works with the code I posted in this post e.g being able to send an email from the mail form to my gmail address. Thanks.
Is this a windows server or linux server? In linux you do not need to specify the SMTP server in your php.ini as it uses the sendmail functionality in linux.
On a Windows server you should designate the SMTP server you use in your php.ini by adjusting the values for these lines..
It's for windows. The "sendmail_from" will it be your email address used for receiving emails from the mail form? And where do you execute the php.ini script in the mail form script?
Or rather how does the php.ini script executes? I know I have to test the mailform script on the web hosting service I am using so if I just upload the php.ini script on the hosting service, will my mailform automatically detect the php.ini script?
the php.ini file located in C:\Program Files\PHP, is that the file that needs to be edited in order for your smtp configuration to work? And if so, it does not need to be copied to C:\Windows? I am getting this part when running phpinfo() for the config file which I don't understand - /etc/php-users.ini
I located the mail function settings in the php.ini file stored in the php folder located in C:\program files but when i uploaded my mail form script and tried executing it, it still does not work.
I have been able to send an email via localhost to the recepient email address. I used this tutorial link that helped - http://drupal.org/node/30079 . What I want to know, is now I want to test my mail script on the web hosting service I am using. In order for me to do this, what exactly do i need to do? Do I upload the php.ini to my web hosting account and call it in the mailform script for the mail form script to work?
Since no one has replied, as mentioned I have been able to get the php mail() function to work using the smtp virtual server and I have found out that the web hosting service I use may not allow smtp out going mail (I have posted a question on the zymic forum, hopefully someone will get back to me). If anyone knows another free web hosting service that offers smtp outgoing mail, I'd appreciate if you can let me know. Thanks.