Jump to content

Recommended Posts

Posted

The mail function needs a minimum of 3 parameters.

To, Subject and Message are required, Additional headers and Parameters are optional, although the From header is suggested to avoid becoming Spam.

 

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

 

 

http://ca.php.net/manual/en/function.mail.php

Posted

1. When I go to this page, an email is automatically sent to my inbox.

here i would use the conditional statement after you validate all the user input, for example:

 

if($_POST['button']){

mail($to, $subject, $message, $headers);

}

 

this way it only sends the message when you push the send button

 

2. I write the email address in ?Email? box, but it not appears in the email received, it just says ?From: "$_POST@yahoo.com" <$_POST@yahoo.com>".

 

and here what i would do is put the

elements into the html. such as

and then assign the user input in email the the variable $email like this

 

 

$email=$_POST['email'];

 

$to = 'nobody@example.com';

$subject = 'the subject';

$message = 'hello';

$headers = "From: $email" . "\r\n" .

'Reply-To: webmaster@example.com' . "\r\n" .

'X-Mailer: PHP/' . phpversion();

Posted (edited)

I made the changes as you told, but it still give error.

At this time, no email is sent to my inbox.

 

My new code is:

 

<?php

if($_POST['button']){
mail($to, $subject, $message, $headers);
}

$email=$_POST['email'];

$to      = $_POST['email'];
$subject = $_POST['name'];
$message = $_POST['message'];
$headers = "From: $email" . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

?>

 

The error I receive is:

 

Warning: mail() [function.mail]: SMTP server response: 503 Bad sequence of commands. You must specify the recipients of a message before you can send it in E:\inetpub\vhosts\fazlionline.com\httpdocs\school\send_email_01.php on line 4

 

What is the solution?

 

check it here: http://www.fazlionline.com/school/send_email_01.php

Edited by fazlionline
Posted

Send us your feed back:


 

<?php

 

if ($_POST && isset($missing) && !empty($missing)) {

?>

Please complete the missing item(s) indicated.

<?php

}

elseif ($_POST && $mailsent = false) {

?>

Sorry, there was a problem sending your message.

Please try later.

<?php

}

elseif ($_POST && $mailsent = true) {

?>

 

Your message has been sent. Thank you for your feedback.

<?php } ?>

 

 

Name:

<?php if(isset($missing) && in_array('name', $missing)) { ?> :Please enter your name <?php }?>

 

Email:

<?php if(isset($missing) && in_array('email', $missing)) { ?> :Please enter your email <?php }?>

Message:

<?php if(isset($missing) && in_array('message', $missing)) { ?> Please enter your Message: <?php }?>

<?php

if (isset($missing)) {

echo htmlentities($_POST['message']);

} ?>

 

Posted (edited)

hello cugopob.vlad

i tried your code, is too lengthyit and gives error,

 

Method Not Allowed

The HTTP verb used to access this page is not allowed.

 

see it here: http://www.fazlionline.com/school/killer01.html

 

 

I liked jlhaslip's Script

hi jlhaslip, will u plz help me just to add one field for email only!!!

 

or see the form agian:

http://www.fazlionline.com/school/email01.html

 

 

Thansk

Edited by fazlionline
Posted
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$message .= "\r\n";
$message .= $_POST['uremail'];
$message .= "\r\n";
$message .= 'End message';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...