Results 1 to 8 of 8

Thread: php mail function

  1. #1
    Join Date
    Dec 2004
    Posts
    10

    Default php mail function

    this seem not to work. anyone know why?
    thanks

  2. #2
    Join Date
    Dec 2004
    Posts
    9

    Default Language

    what language use?

  3. #3
    Join Date
    Dec 2004
    Posts
    10

    Default

    php, please do not spam this forum

  4. #4

    Default

    why?
    why can't be used?

  5. #5
    Join Date
    Dec 2004
    Posts
    20

    Default

    try using this function:
    function sendmail ($from_name, $from_email, $to_name, $to_email, $subject, $text_message="", $html_message, $attachment="")
    {
    $from = "$from_name <$from_email>";
    $to = "$to_name <$to_email>";
    $main_boundary = "----=_NextPart_".md5(rand());
    $text_boundary = "----=_NextPart_".md5(rand());
    $html_boundary = "----=_NextPart_".md5(rand());
    $headers = "From: $from\n";
    $headers .= "Reply-To: $from\n";
    $headers .= "X-Mailer: Hermawan Haryanto (http://hermawan.com)\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"$main_boundary\"\n";
    $message .= "\n--$main_boundary\n";
    $message .= "Content-Type: multipart/alternative;\n\tboundary=\"$text_boundary\"\n";
    $message .= "\n--$text_boundary\n";
    $message .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\n";
    $message .= "Content-Transfer-Encoding: 7bit\n\n";
    $message .= ($text_message!="")?"$text_message":"Text portion of HTML Email";
    $message .= "\n--$text_boundary\n";
    $message .= "Content-Type: multipart/related;\n\tboundary=\"$html_boundary\"\n";
    $message .= "\n--$html_boundary\n";
    $message .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n";
    $message .= "Content-Transfer-Encoding: quoted-printable\n\n";
    $message .= str_replace ("=", "=3D", $html_message)."\n";
    if (isset ($attachment) && $attachment != "" && count ($attachment) >= 1)
    {
    for ($i=0; $i<count ($attachment); $i++)
    {
    $attfile = $attachment[$i];
    $file_name = basename ($attfile);
    $fp = fopen ($attfile, "r");
    $fcontent = "";
    while (!feof ($fp))
    {
    $fcontent .= fgets ($fp, 1024);
    }
    $fcontent = chunk_split (base64_encode($fcontent));
    @fclose ($fp);
    $message .= "\n--$html_boundary\n";
    $message .= "Content-Type: application/octetstream\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-Disposition: inline; filename=\"$file_name\"\n";
    $message .= "Content-ID: <$file_name>\n\n";
    $message .= $fcontent;
    }
    }
    $message .= "\n--$html_boundary--\n";
    $message .= "\n--$text_boundary--\n";
    $message .= "\n--$main_boundary--\n";
    $mail_resut = mail ($to, $subject, $message, $headers);
    return $mail_result;
    }

  6. #6
    Join Date
    Dec 2004
    Location
    Mel - Aus
    Posts
    34

    Default Ok

    Lets try something simple...

    <?php
    //The Person you want to send to
    $reciever = "[email protected]";
    //The subject of the email
    $subject = "Test Mail";
    //The Message (Note /n/r/n, is the code for you empty lines!)
    $body = "Hello/n/r/nThis is a test message";
    //Sender Address
    $sender = "[email protected]";
    //Reply Address - can be the same as sender address
    $reply = "[email protected]";


    mail("$reciever", "$subject", "$body",
    "From: $sender\\r\\n
    Reply-to: $reply\\r\\n
    X-Mailer: A nice little mailer\\r\\n");
    ?>

  7. #7
    Join Date
    Oct 2004
    Location
    Malaysia,
    Posts
    321

    Default

    Looks great & Simple!!

  8. #8
    Join Date
    Dec 2004
    Location
    malaysia
    Posts
    23

    Default

    yes that simple .. but cannot working ...

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
  •