Jump to content

[SOLVED] emailing with php


enemeth

Recommended Posts

hi there,

 

I have been working on this for days now, and figured i would get some help to finish this little project im on in here

 

so if anyone can help with this little coding problem im having it would be much appreciated,

 

The code works , its intention was to send an attachment with php , which it does, but i cant seem to get all the information from the form on the website to be emailed along with it, heres the code:

 

<?php

$my_email = "elainenemeth@hotmail.com";

$from    = $_POST['from'];

$subject = $_POST['subject'];

$message = $_POST['message'];

 

$fileatt      = $_FILES['fileatt']['tmp_name'];

$fileatt_type = $_FILES['fileatt']['type'];

$fileatt_name = $_FILES['fileatt']['name'];

 

$headers = "From: $from";

 

if (is_uploaded_file($fileatt)) {

  $file = fopen($fileatt,'rb');

  $data = fread($file,filesize($fileatt));

  fclose($file);

 

  $semi_rand = md5(time());

  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

 

 

  $headers .= "\nMIME-Version: 1.0\n" .

              "Content-Type: multipart/mixed;\n" .

              " boundary=\"{$mime_boundary}\"";

 

  $message = "This is a multi-part message in MIME format.\n\n" .

            "--{$mime_boundary}\n" .

            "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .

            "Content-Transfer-Encoding: 7bit\n\n" .

            $message . "\n\n";

 

 

  $data = chunk_split(base64_encode($data));

 

  $message .= "--{$mime_boundary}\n" .

              "Content-Type: {$fileatt_type};\n" .

              " name=\"{$fileatt_name}\"\n" .

              "Content-Transfer-Encoding: base64\n\n" .

              $data . "\n\n" .

              "--{$mime_boundary}--\n";

}

$ok = @mail($my_email, $subject, $message, $headers);

if ($ok) {

  echo "<p>Mail sent! Yay PHP!</p>";

} else {

  echo "<p>Mail could not be sent. Sorry!</p>";

}

[code=php:0]

 

the form is here:

 

 

      <form action="mail.php" method="POST" enctype="multipart/form-data">

        <table border="0" width="99%">

          <tr>

            <td width="69%" align="right" colspan="2">

            </td>

          </tr>

          <tr>

            <td width="31%" align="right"><font face="Arial" font size="2" font color="#333333">

              Name:

              </font>

            </td>

            <td width="38%"><input type="text" name="from"  size="25"></td>

          </tr>

          <tr>

            <td width="31%" align="right"><font size="2" font face="Arial" color="#333333">Your

              Specialty: </font>

            </td>

            <td width="38%"><select size="1" name="subject">

            <option>Accounting & Finance</option>

            <option>Advertising & Marketing</option>

            <option>Aerospace & Avionics</option>

            <option>Consumer Products</option>

            <option>Engineering</option>

            <option>Hospitality</option>

            <option>Human Resources</option>

            <option>Manufacturing/Supply Chain</option>

            <option>Medical/Biotech/Pharmaceutical</option>

            <option>Technology</option>

            <option>Other</option>

 

              </select><font face="Arial" size="2">other<input type="text" name="email"

 

size="18"></font></td>

          </tr>

          <tr>

            <td width="31%" align="right"><font face="Arial" font size="2" font color="#333333">Email:

              </font>

            </td>

            <td width="38%"><input type="text" name="phone" size="25"></td>

          </tr>

          <tr>

            <td width="31%" align="right"><font face="Arial" font size="2" font color="#333333">Phone

              Number:

              </font>

            </td>

            <td width="38%"><input type="text" name="message" size="25"></td>

          </tr>

          <tr>

            <td width="31%" align="right"><font size="2" face="Arial" color="#333333">Resume: (word document

 

only)</font>

            </td>

            <td width="38%"><input type="file" name="fileatt" /></td>

          </tr>

          </table>

          <p align="center"><input type="submit" value="Send" /><input type="reset" value="Reset"

 

name="B2"></p>

        </form>

 

 

It would be wonderful if someone can tell me what i am missing to get the email address, the phone number included in the email that is sent ! 

 

thank you much ;)

 

Elaine

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.