Send Mail Scrip Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Send Mail Scrip Problem

Post by Zeceer »

I got this script and have configured it. When I use the script I get a message that the e-mail was sent. But I never recive it. What can be wrong?

Code: Select all

<?php

    /*
     * FileAttach - Attaches File to Email
     *   Unknown origin of this code - Modified by Craig Donnelly (craig@evilwalrus.com || craig@develop3r.net)
     */

    $fileatt = "title.php"; // Path to the file
    $fileatt_type = "application/octet-stream"; // File Type
    $fileatt_name = "title.php"; // Filename that will be used for the file as the attachment

    $email_from = "zeceer@hotmail.com"; // Who the email is from
    $email_subject = "Heres your file..."; // The Subject of the email
    $email_message = "Hello Man"; // Message that the email has in it

    $email_to = "zeceer@hotmail.com"; // Who the email is too

    $headers = "From: ".$email_from;

        $file = fopen($fileatt,'rb');
        $data = fread($file,filesize($fileatt));
        fclose($file);

    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x&#123;$semi_rand&#125;x";

    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary="&#123;$mime_boundary&#125;"";
    $email_message = "This is a multi-part message in MIME format.\n\n" . "--&#123;$mime_boundary&#125;\n" . "Content-Type:text/html; charset="iso-8859-1"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";

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

    $email_message .= "--&#123;$mime_boundary&#125;\n" . "Content-Type: &#123;$fileatt_type&#125;;\n" . " name="&#123;$fileatt_name&#125;"\n" . "Content-Disposition: attachment;\n" . " filename="&#123;$fileatt_name&#125;"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" ."--&#123;$mime_boundary&#125;--\n";

    $ok = @mail($email_to, $email_subject, $email_message, $headers);

    if($ok) &#123;
        echo "<font face=verdana size=2>The file was successfully sent!</font>";
    &#125;else&#123;
        die("Sorry but the email could not be sent. Please go back and try again!");
    &#125;
?>
Post Reply