00stuff Posted July 14, 2011 Share Posted July 14, 2011 I"m trying to send email with PHP and go an Internal Error 500 on my server. I think it might be my script. Can some one tell me if ther is something wrong with it please? <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $phone = $_POST['phone']; $email = $_POST['email']; $message2 = 'First Name: " . $name_first . " Last Name: " . $name_last . " Phone: " . $phone . " Email: " . $email . "'; $to = '" . $receive_email . "'; $subject = 'Registration to " . $company_name . "'; $message = $message2; $from = '" . $receive_email . "'; $headers = 'From:' . $from; mail($to,$subject,$message,$headers); echo 'Mail Sent. Click <a href="register.php">here</a> to go back!'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/241997-im-trying-to-send-email-with-php/ Share on other sites More sharing options...
premiso Posted July 14, 2011 Share Posted July 14, 2011 You are mixing up your quotes, you need to stay consistent, either use single or doubles. You only need 1 set of quotes. I would suggest looking at PHP's Basic Syntax before you venture further on, as this is programming 101. Quote Link to comment https://forums.phpfreaks.com/topic/241997-im-trying-to-send-email-with-php/#findComment-1242750 Share on other sites More sharing options...
AyKay47 Posted July 14, 2011 Share Posted July 14, 2011 your code is a mess and needs cleaned up, I will clean it up for you. Also, view the link that premiso provided for more information on using correct parse syntax for variables inside of double quotes.. Do you receive any parse errors? <?php $name_first = $_POST['name_first']; $name_last = $_POST['name_last']; $phone = $_POST['phone']; $email = $_POST['email']; $message = "First Name: $name_first \n Last Name: $name_last \n Phone: $phone \n Email: $email \n"; $to = "$receive_email"; $subject = "Registration to $company_name"; $from = "$receive_email"; $headers = "From: $from"; $mail = mail($to,$subject,$message,$headers); if(!$mail){ ini_set('track_errors,1'); print $php_errormsg; }else{ print 'Mail Sent. Click <a href="register.php">here</a> to go back!'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241997-im-trying-to-send-email-with-php/#findComment-1242753 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.