is php mail() function working?
i have a registration script that send applicants an email when registering. Was testing by sending to my personal email but the mail doesnt get sent. my script is absolutely as it returns true when mail() is invoked.
is php mail() function working?
i have a registration script that send applicants an email when registering. Was testing by sending to my personal email but the mail doesnt get sent. my script is absolutely as it returns true when mail() is invoked.
Last edited by web.houstontoh88; 04-23-2011 at 01:45 AM.
Yes as far as i can tell. i use the mail() function on my basic contact form at My Website .Hope this helps.
no it is sent to send to me.
Here is a basic working contact form in php using mail()
save as contact.phpCode:<?php function spamcheck($field) { //filter_var() sanitizes the e-mail //address using FILTER_SANITIZE_EMAIL $field=filter_var($field, FILTER_SANITIZE_EMAIL); //filter_var() validates the e-mail //address using FILTER_VALIDATE_EMAIL if(filter_var($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_REQUEST['email'])) {//if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==FALSE) { echo "Try Again"; } else {//send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("YOUREMAIL", "Subject: $subject", $message, "From: $email" ); echo "Thank you, your email has been sent."; } } else {//if "email" is not filled out, display the form echo "<div style='padding:5px;'><form method='post' action='contact.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' value='Send' /> </form></div>"; } ?>
Last edited by mrnutt; 04-23-2011 at 03:17 AM. Reason: Show code
so did u recieved an email where its from toh.houston@gmail.com?
yes 2
The best tutorial (I think) is put here.
This worked for me.I put that on my sites too.
http://www.w3schools.com/PHP/php_mail.asp
Regs,
VVBB
█ BCV | Community Support Representative
█ x10Hosting - Giving Away Hosting Since 2004
█ Premium Hosting | VPS Services
do i have to set up anything to use the email provided by x10hosting in this function ?
is this literally the code, because "YOUREMAIL" is not defined anywhere. Perhaps your just hiding the email for posting purposes?
Also if you use $_REQUEST you have no guarantee that the data came from the post data, which leads to security holes in your script. Use $_POST to grantee that's not the problem.