Current location: Hot Scripts Forums » Programming Languages » PHP » Is it possible to Send an image created on fly as attachement?


Is it possible to Send an image created on fly as attachement?

Reply
  #1 (permalink)  
Old 03-05-06, 05:04 AM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Question Is it possible to Send an image created on fly as attachement?

Hi All,

i went through this issue:

I have a result page with an image created on fly, i would like to let the user email him/her self that image as attachment, the image i.e the image.php?name=John&surname=doe... etc

it creates some kind of Vcard on fly according to the user input , all i want to do is let the user email him/her that vcard, without having to right click save as, then open email and attached,

any idea how to do that?

Cheers
Nitro
Reply With Quote
  #2 (permalink)  
Old 03-05-06, 09:27 AM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
People are just going to send you to this link

http://phpmailer.sourceforge.net/

There mailer attaches files(or so i've heard). I've looked and looked. I can't figure out how to attach a file, that website isn't helping me. There has to be a easyer way to attach a file to a email. Can someone help use both?

My PHP Mailer!
PHP Code:

// START // Send eMail

}elseif($_GET['page'] == "sendemail"){
    
$result mysql_query("SELECT * FROM list");
    while(
$row mysql_fetch_array($result)) {
    
$date date ("l, F jS, Y"); 
    
$time date ("h:i A"); 
    
$id "$row[id]";
    
$name "$row[name]";
    
$email "$row[email]";
    
$message $_POST['message'];
    
mail ("$email""$subject""$message""From: $email\r\nReply-to:$admin_email");
    echo(
"eMail Sent to: $name at, <a href=\"mailto:$email\">$email</a><br>");
    }
    echo(
"
        <hr color=#000000>
        <font class=textbig>
$subject</font><BR>
        <font class=texbigt>
$message</font>
    "
);
// END // Send eMail 
I want to attact file.... (test.zip) How would I go about doing this.

Thanks Keith
Reply With Quote
  #3 (permalink)  
Old 03-05-06, 09:49 AM
nitro4file nitro4file is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
To Send a mail with attachement it's quite simple, what i want to do is send a mail with a an image what was created on fly as i explain above, for you i have the following script:

the PHP SCRIPTmail.php)
<html>
<head>
<title> Sending Email </title>
</head>
<body>
<?php
// Read POST request params into global vars
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];

// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];

$headers = "From: $from";

if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

// Add a multipart boundary above the plain message
$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";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$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";
}

// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Mail sent! Yay PHP!</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
</body>
</html>

NOW the HTML

<html>
<head>
<title>Send an Email</title>
</head>
<body>
<h1>Send an Email</h1>
<form action="mail.php" method="POST" enctype="multipart/form-data">
<p>To: <input type="text" name="to" value="" /><br />
From: <input type="text" name="from" value="" /><br />
Subject: <input type="text" name="subject" value="" /></p>
<p>Message:<br />
<textarea cols="70" rows="20" name="message"></textarea></p>
<p>File Attachment: <input type="file" name="fileatt" /></p>
<p><input type="submit" value="Send" /></p>
</form>
</body>
</html>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send a image in the mail jaishalg PHP 2 06-29-05 12:58 PM
Help with image on form... Adrianaa03 JavaScript 1 10-06-04 07:38 AM
how to draw an image inside a table? davidklonski HTML/XHTML/XML 2 07-06-04 10:27 AM


All times are GMT -5. The time now is 06:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.