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 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? 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. 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
Archived
This topic is now archived and is closed to further replies.