Results 1 to 4 of 4

Thread: phpmailer

  1. #1
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default phpmailer

    so i found this script. can anyone help me set it up.

    i guess i would just have a form but how do i have it so the form sends using the following script?

    the code is located here http://davidmorin.net/mailer/phpmailer.txt

    thanks in advance

  2. #2
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Tell me what you actually NEED the form to do - will it be dealing with attachments? If it isn't too complicated, like simply sending information, then a much simpler script will work better for you.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  3. #3
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    all i want is a form that a user inputs there email and when they hit send it sends them and email with a picture/mp3 in it. so just a basic script. this is what ive come up with so far
    Code:
    <?php
    $to = $_POST['email']; 
    $from = 'test@gmail.com';
    $subject = 'Just what you ordered';
    
    $boundary = 'Message-Boundary-' . date('YmdHis');
    
    $headers = 'From: ' . $from . "\n";
    $headers .= 'Reply-To: ' . $from . "\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: Multipart/Mixed; boundary=' . $boundary . "\n\n";
    
    $message = '--' . $boundary . "\n";
    $message .= 'Content-Transfer-Encoding: 7BIT' . "\n";
    $message .= 'Content-Type: text/html; charset=US-ASCII' . "\n\n";
    
    $message .= 'This is the body of the message in HTML.';
    
    $attach = false;
    if($attach){
      $arrfile = array('file1.jpg', 'file2.jpg');  //// your files here 
      foreach($arrfile as $f){
        $file = $f;
        $attach = fopen($file, 'rb');
        $data = fread($attach, filesize($file));
        fclose($attach);
        $data = chunk_split(base64_encode($data)); 
    
        $ext = strtolower(substr(strrchr($file, '.'), 1));
        switch($ext){
          case 'pdf': $type = 'application/pdf'; break;
          case 'exe': $type = 'application/octet-stream'; break;
          case 'zip': $type = 'application/zip'; break;
          case 'doc': $type = 'application/msword'; break;
          case 'xls': $type = 'application/vnd.ms-excel'; break;
          case 'ppt': $type = 'application/vnd.ms-powerpoint'; break;
          case 'gif': $type = 'image/gif'; break;
          case 'png': $type = 'image/png'; break;
          case 'jpe':
          case 'jpeg':
          case 'jpg': $type = 'image/jpg'; break;
          default: $type = 'application/force-download';
        }
    
        $message .= "\n\n" . '--' . $boundary . "\n";
        $message .= 'Content-Transfer-Encoding: base64' . "\n";
        $message .= 'Content-Type: ' . $type . '; name="' . $file . '";' . "\n";
        $message .= 'Content-Disposition: inline; filename="' . $file . '"' . "\n\n" . $data;
      }
    }
    
    mail($to, $subject, $message, $headers);
    echo 'E-mail sent!';
    ?>
    and the form:
    Code:
    <?php
    if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
      {
      //send email
      $email = $_REQUEST['email'] ; 
      mail( "someone@example.com", "Subject: $subject",
      $message, "From: $email" );
      echo "Thank you for using our mail form";
      }
    else
    //if "email" is not filled out, display the form
      {
      echo "<form method='post' action='mailform.php'>
      Email: <input name='email' type='text' /><br />
      <input type='submit' />
      </form>";
      }
    ?>
    i have worked really hard and this does not work. Can you test it on your server and see if it does? This is killing me.

  4. #4
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    The php mail() function can bog a server down. Why not use swift? See http://www.swiftmailer.org

Bookmarks

Posting Permissions

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