Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function to send mail in PHP

    Hi
    Others visit your site and give their opinions right from the website. Here is a function that I want to use, can I use it well?
    The code is as follows:
    <?php
    $name = "customer";
    $email = "[email protected]";
    $subject = "Feedback";
    $message = "This is my comment";

    mail("[email protected]", "$name", "$email", "$subject", $message);
    ?>

  2. #2
    Supreme Master coder!
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    10,378
    Thanks
    10
    Thanked 1,190 Times in 1,180 Posts
    From what you posted, it sounds like you might be very new to PHP. There's more to sending email than just a small, simple script using mail().

    You need a form for them to fill out, and then you need to bit of filtering to make sure people are not trying to send things that are malicious.

    Not all webhosts allow the use of mail(). Some require other methods. Then, you have to figure out a way to keep spammers and spamming robots from using your form.

    To see the very basic use of mail(), see this:
    PHP: mail - Manual

    You can already see you have 5 things in your mail function. You seem to have them in the wrong places, so right out of the box you will have problems.

    Nothing wrong with experimenting .... see some of the PHP examples in the manual. Play around and see what your webhost allows and does not allow. If you can get your script to send yourself an email, that would be a good thing. You'll have learned something new.
    Last edited by mlseim; Dec 25th, 2018 at 09:37 PM.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •