Sending mails with Php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • punitshrivastava
    New Member
    • Jul 2007
    • 22

    Sending mails with Php

    Hi .this is punit .I am back with one question on php.
    I want make mail option in my project .please tell me how i code for sending mail option in php.As i am new in php so please suggest me how i proceed.
    Thanks & Regards.
    Punit Shrivastava
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Originally posted by punitshrivastav a
    Hi .this is punit .I am back with one question on php.
    I want make mail option in my project .please tell me how i code for sending mail option in php.As i am new in php so please suggest me how i proceed.
    Thanks & Regards.
    Punit Shrivastava
    I think there are lots of threads here, about php mail function.
    Search Results

    Additionally you may take a look at on php mail funtion

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Hope the current thread title makes good traffic on the thread rather than the Original:

      Disscusion for sending mail

      Comment

      • punitshrivastava
        New Member
        • Jul 2007
        • 22

        #4
        Hi Ajaxrand,
        Thanks for suggesting.I code for contact form like this:
        for 1st form :
        [code=html]
        <table width="400" border="0" align="center" cellpadding="3" cellspacing="1" >
        <tr>
        <td><strong>Con tact Form </strong></td>
        </tr>
        </table>

        <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" >
        <tr>
        <td><form name="form1" method="post" action="mailfor m.php">
        <table width="100%" border="0" cellspacing="1" cellpadding="3" >
        <tr>
        <td width="16%">Sub ject</td>
        <td width="2%">:</td>
        <td width="82%"><in put name="subject" type="text" id="subject" size="50"></td>
        </tr>
        <tr>
        <td>Detail</td>
        <td>:</td>
        <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
        </tr>
        <tr>
        <td>Name</td>
        <td>:</td>
        <td><input name="name" type="text" id="name" size="50"></td>
        </tr>
        <tr>
        <td>Email</td>
        <td>:</td>
        <td><input name="customer_ mail" type="text" id="customer_ma il" size="50"></td>
        </tr>
        <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
        </tr>
        </table>
        </form>
        </td>
        </tr>
        </table>
        [/code]
        And for 2nd form i code like this :
        [code=php]
        <?php
        // Contact subject
        $subject ="$subject";
        // Details
        $message="$deta il";

        // Mail of sender
        $mail_from="$cu stomer_mail";
        // From
        $header="from: $name <$mail_from>" ;

        // Enter your email address
        $to ='YOU@YOURDOMAI N.COM';

        $send_contact=m ail($to,$subjec t,$message,$hea der);

        // Check, if message sent to your email
        // display message "We've recived your information"
        if($send_contac t){
        echo "We've recived your contact information";
        }
        else {
        echo "ERROR";
        }
        ?>
        [/code]
        But its shows error As it disply :-
        Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for YOU@YOURDOMAIN. COM in C:\Uniform3_1_1 s\www\abc\mailf orm.php on line 23
        ERROR .
        Please suggest me about code .As i am new in php so kindly give me suggestion regarding to code.

        Originally posted by ajaxrand
        I think there are lots of threads here, about php mail function.
        Search Results

        Additionally you may take a look at on php mail funtion
        Please use code tags [code=php] .........[ /code] - ajaxrand
        Last edited by ak1dnar; Aug 8 '07, 11:16 AM. Reason: Email Addresses NOT Allowed in technical forums

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          Nice work ! There is No problem with your html form. But there are few issues with php script.

          Didn't you try to get the POSTed values to Variables
          [CODE=php]$your_variable_ name = $_POST['html_form_elem ent'];[/CODE]

          I didn't see them on the script.

          Then The Error says something Like this, Your SMTP server doesn't allow you to send the mails.

          If you are trying this on a Local server Set up your SMTP server to send mails.

          Comment

          Working...