Jump to content

more mail problems


monkeymade

Recommended Posts

OK, I have been working on this for about 5 days now.... I am trying to make a script that will send an email with an attachement.... Here is the code, started from the where I start to insert the file:

 

$fileatt_type = $filetype; 
$fileatt_name = $nameuse;
$usefile = "/home/bodenpho/public_html/uploads/$nameuse";
$file = fopen($usefile,'rb'); 
$data = fread($file,filesize($usefile)); 
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-Disposition: attachment;\n" . 
             " filename=\"{$fileatt_name}\"\n" . 
             "Content-Transfer-Encoding: base64\n\n" . 
             $data . "\n\n" . 
             "--{$mime_boundary}--\n";
             
$ok = @mail($to, $subject, $message, $headers); 
if ($ok) 
{  
} 
else 
{ 
	echo "<p>Mail could not be sent. Sorry!</p>"; 
}

 

Ok, when I run this, I am getting the file in my e-mail, but, its not in a useable form.  Instead of getting the picture, I get a ton of lines of code for the picture, not exactly what I was hoping for lol.

 

Someone tell me what I am doing wrong please

Link to comment
https://forums.phpfreaks.com/topic/47132-more-mail-problems/
Share on other sites

Try this http://zigmoyd.sourceforge.net/man/mail.php#mailIts very Simple Here

<?php
//Sending Mails With Extra Headers Simply By Using Headers Arrays
$ext["Cc"] = "demo1@localhost, demo2@localhost";
$ext["Bcc"] = "postmaster@localhost, admin@localhost";
$ext["attach"] = "atch.txt,test.wav";
$mail = new mail("admin@localhost", "Mail Subject", "Mail Body", $ext);
if(!$mail->send())
    {
        echo "Mail Not Sent Succfully\n";
        print_r($mail->error);//Print The Errors
    }
else 
    {
        echo "Mail Sent Successfully\n";
    }
?>

But Please Read the Installation Instruction before Using http://zigmoyd.sourceforge.net/man/index.php

Link to comment
https://forums.phpfreaks.com/topic/47132-more-mail-problems/#findComment-229826
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.