bilalaslam777 Posted August 7, 2009 Share Posted August 7, 2009 Hello Guys,it's Urgent can anybody tell me how to send an email in php and how to integrate my code with SMTP. i have this code <?php $to=$_POST['to']; $subject=$_POST['subject']; $message=$_POST['message']; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $to)) { echo "Email address is not valid. Please try again..."; } else { if(mail($to,$subject,$message)) { echo "Mail has successfully been sent to $mailto<br>"; echo "Your message was!<br>$mailmessage"; } else { echo "Sorry! Mail sending failed"; } } ?> is there anything else i have to do with this. Thanks in Advance Quote Link to comment https://forums.phpfreaks.com/topic/169248-solved-how-to-send-email-in-php/ Share on other sites More sharing options...
mikesta707 Posted August 7, 2009 Share Posted August 7, 2009 http://us3.php.net/manual/en/function.mail.php also, wrap your code with code tags. have you ran that code? what seems to be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/169248-solved-how-to-send-email-in-php/#findComment-893089 Share on other sites More sharing options...
MatthewJ Posted August 7, 2009 Share Posted August 7, 2009 You have to have a configured smtp server on the webserver. Other than that the code should work. Quote Link to comment https://forums.phpfreaks.com/topic/169248-solved-how-to-send-email-in-php/#findComment-893119 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.