I've noticed that my test email isn't always sent. Then I checked my mailbox on my host and found 19 notices:

Subject: Mail failure - no recipient addresses
From: "Mail Delivery System" <Mailer-Daemon@server1.host.net>
Date: Sun, July 27, 2003 2:51 am
To: admin@doof.us
Priority: Normal
A message that you sent contained no recipient addresses, and therefore no
delivery could be attempted.

All I'm doing is testing my tell-a-friend which simply posts from a form page to the mailer.php...but, as stated above, it doesn't always post the email recipient's address.

Is there a way to back this up to make sure the users email address variable is always posted into mail($email,$subject,$message,$headers); because it seems to be failing fairly frequently.

Thanks 😕

    What's code are you using? I would use something along these lines:

    <form action="tellafriend.php" method="post">
         <input type="text" name="email" />
         <input type="submit" name="submit" value="Tell A Friend" />
    </form>

    Then use $_POST['email'] to access that value.

      I didn't have $_POST['email']; in there.
      Will this work?

      $_POST['email'] = '$email';
      mail($email,$subject,$message,$headers);

      Thanks

        No, it won't work ... you need to do this:

        $email = $_POST['email'];

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

        Might be good to check if the address is formatted properly with a RegEx, and unless you have set the subject and message yourself, you may want to remove possibly nasty stuff - like HTML tags, or code. But that's another topic.

          Write a Reply...