Page 1 of 1

php contact form

Posted: Fri Jul 10, 2015 3:29 am
by wanjali
That's the code that I am using, but it is not working. Can anyone help?
In the form I am asking for name and email address to subscribe. But this is the error message that comes
PHP Warning: mail(): SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in D:\inetpub\vhosts\legalyaar.com\httpdocs\contact.php on line 9

Code: Select all

<?php
	
	$name = $_POST['name'];
	$email = $_POST['email'];
	$message = $_POST['message'];
	
	$formcontent="Name: $name\n\nEmail: $email\n\nMessage: $message";
	
	// Enter the email where you want to receive the notification when someone submit form
	$recipient = "anjali@legalyaar.com";
	
	$subject = "Comingsoon! Contact Form";
	
	$mailheader = "From: $email\\r\\n";
	$mailheader .= "Reply-To: $email\\r\\n";
	$mailheader .= "MIME-Version: 1.0\\r\\n";
	
	$success = mail($recipient, $subject, $formcontent, $mailheader);
	
	if ($success == true){
	
?>
	
	<script language="javascript" type="text/javascript">
		alert('Thank you for subscribing to our newsletters.');
		window.location = "../index.html";
	</script>
	
<?php
	
	} else {
	
?>

    <script language="javascript" type="text/javascript">
		alert('Message not sent.');
		window.location = "../index.html";
    </script>
	
<?php

    }
	
?>

Re: php contact form

Posted: Fri Jul 10, 2015 5:13 am
by requinix
"it is not working" doesn't mean anything to us. How is it not working? What did you expect it to do and what did it actually do?

Code: Select all

$mailheader = "From: $email\\r\\n";
$mailheader .= "Reply-To: $email\\r\\n";
$mailheader .= "MIME-Version: 1.0\\r\\n";
Those backslashes must not be escaped. You do want the actual \r and \n characters in there.

Re: php contact form

Posted: Fri Jul 10, 2015 5:19 am
by smithedison
may i know what actually error you seen whenever you run this program

Re: php contact form

Posted: Fri Jul 10, 2015 6:15 am
by wanjali
Sorry, I am new to this. Thanks for letting me know how it works here.

I expected this code to let a person subscribe to my email list by entering name & email. However it is giving the said error... and not sending a mail with the information entered by the user.
requinix wrote:"it is not working" doesn't mean anything to us. How is it not working? What did you expect it to do and what did it actually do?

Code: Select all

$mailheader = "From: $email\\r\\n";
$mailheader .= "Reply-To: $email\\r\\n";
$mailheader .= "MIME-Version: 1.0\\r\\n";
Those backslashes must not be escaped. You do want the actual \r and \n characters in there.

Re: php contact form

Posted: Fri Jul 10, 2015 6:17 am
by wanjali
Error message
PHP Warning: mail(): SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in D:\inetpub\vhosts\legalyaar.com\httpdocs\contact.php on line 9






requinix wrote:"it is not working" doesn't mean anything to us. How is it not working? What did you expect it to do and what did it actually do?

Code: Select all

$mailheader = "From: $email\\r\\n";
$mailheader .= "Reply-To: $email\\r\\n";
$mailheader .= "MIME-Version: 1.0\\r\\n";
Those backslashes must not be escaped. You do want the actual \r and \n characters in there.

Re: php contact form

Posted: Fri Jul 10, 2015 6:28 am
by Celauran
I see you're using Windows, which doesn't have a built-in mail server. Do you have a mail server configured or have you configured the SMTP settings for PHP?