How to send form data to email id by using PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Malli mindwave

    How to send form data to email id by using PHP

    Hi,

    We are using the yahoowebHostiin g service for my company website, In
    that one screen of the SendComments/FeedBack section is there, I'm
    basically dot.net develeoper ,but yahoowebhosting not
    support .asp,.aspx files, it supports PHP files,

    I'm searching in JavaScript ,but not found any matter,
    I'don't Know PHP.I'm having lot of pressure of higer officials.Pleas e
    help me on this.
    Please give the Details of the PHP to send form data to given mail id
    Name,email,phon eNo, Commnets....... ....thease are the fileds and by
    click send it would be come to given to address mail id,
    and how to run the php code, Please send the PHPCODE and Procee,I will
    put it on the server

    thanks

  • Erwin Moller

    #2
    Re: How to send form data to email id by using PHP

    Malli mindwave wrote:
    Hi,
    >
    Hi,

    Welcome here from comp.lang.javas cript.

    We are using the yahoowebHostiin g service for my company website, In
    that one screen of the SendComments/FeedBack section is there, I'm
    basically dot.net develeoper ,but yahoowebhosting not
    support .asp,.aspx files, it supports PHP files,
    Wise choice. But not very nice for you.
    >
    I'm searching in JavaScript ,but not found any matter,
    I'don't Know PHP.I'm having lot of pressure of higer officials.Pleas e
    help me on this.
    Higher officials seldom care about 'details' like learning a new language
    from scratch. Why should they? They don't have to implement it themselfs..
    ;-)
    Please give the Details of the PHP to send form data to given mail id
    Name,email,phon eNo, Commnets....... ....thease are the fileds and by
    click send it would be come to given to address mail id,
    and how to run the php code, Please send the PHPCODE and Procee,I will
    put it on the server
    Nobody can send you complete code. Too many unknown variables.

    But a good place to start:
    www.php.net then type mail into the searchbox.

    Also look at the mailfunction itself:


    Browse around a little and try to implement some code yourself on your
    server.
    The usercontributed notes contain a lot of usefull information.

    Basicly what you do is this (But PLEASE don't do it like this because all
    kind of ugly hackers will use your site to send spam. This is called
    header-injection. You don't want that.):

    1) Receive the forminformation
    2) assemble the email (body, subject, to who? etc)
    3) send the email

    Suppose your html page has a form with the following elements:
    - email
    - name
    - phonenr
    - comments

    And when the user clicks submit, you want that those 4 elements are send to
    'mallimindwave@ mindwave.com'

    <?php
    // receive the posted formelements, I made up the names myself.
    $email = $_POST["email"];
    $name = $_POST["name"];
    $phonenr = $_POST["phonenr"];
    $comments = $_POST["comment"];

    // Please note that this input MUST be sanitised before using
    // but for the sake of a simple example I don't.

    $subject = "Somebody filled in a form";
    $sendto = 'mallimindwave@ mindwave.com';
    $body = "Hi Malli,\nSomebod y filled in a form.\n\n";
    $body .= "Passed info:\n";
    $body .= "email: $email\n";
    $body .= "name: $name\n";
    $body .= "phonenr: $phonenr\n";
    $body .= "comments: $comments\n";

    // Wordwrap the body to max 70 characters a line:
    $body = wordwrap($body, 70);

    mail($sendto, $subject, $body);

    // done

    ?>

    That is basically all.
    But be warned, even veteran PHP programmers make mistakes with emailing,
    simply because a lot can go wrong.
    Like the abovementioned header-injection.
    Or wrong headers set according to spamfilters, so your email never arives.
    (try sending to hotmail.com if you need a headache)

    You might want to use a lib/class to send email.

    I use HTMLMimeMail a lot, for sending emails that have both text and HTML
    content and/or attachments. (google for it if you want it)

    PHP also have the PEAR packages that contain a good mail class.
    Very good chances they are allready installed on your system.

    Honest warning:
    This might be over your head if you don't even know PHP. :-/
    If you are on a tight deadline, you might consider hiring a PHP programmer
    who did this before to help you out. Setting up a basic emailprogram
    shouldn't take more than a day.

    Good luck.

    Regards,
    Erwin Moller

    >
    thanks

    Comment

    • Jerry Stuckle

      #3
      Re: How to send form data to email id by using PHP

      Malli mindwave wrote:
      Hi,
      >
      We are using the yahoowebHostiin g service for my company website, In
      that one screen of the SendComments/FeedBack section is there, I'm
      basically dot.net develeoper ,but yahoowebhosting not
      support .asp,.aspx files, it supports PHP files,
      >
      I'm searching in JavaScript ,but not found any matter,
      I'don't Know PHP.I'm having lot of pressure of higer officials.Pleas e
      help me on this.
      Please give the Details of the PHP to send form data to given mail id
      Name,email,phon eNo, Commnets....... ....thease are the fileds and by
      click send it would be come to given to address mail id,
      and how to run the php code, Please send the PHPCODE and Procee,I will
      put it on the server
      >
      thanks
      >
      Try googling for PHP and formmail. There are a number of scripts out there.
      Last edited by Rabbit; Feb 16 '15, 04:10 PM. Reason: Advertising

      Comment

      Working...