Click to See Complete Forum and Search --> : how to send an email with attachment?


eto_ya
09-24-2003, 08:24 AM
Hi!
I'm trying to send an email with php from the html form.
It worked well with mail() function, but I coudn't make attachment - I need to enable user to attach an image to his mail.
So I downloaded a class PHPMailer and it sends a mail with attachment.
The only problem is that the image file becomes empty when I get the mail.
Here is my code:

<?php
require("phpmailer/class.phpmailer.php");

$mail = new phpmailer();

$mail->From = "list@example.com";
$mail->FromName = "fri order";
$mail->Host = "smtp1.b-one.nu";
$mail->Mailer = "smtp";

// HTML body
$body = "Hello!";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello again!";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress("order@wasilisa.com");
$mail->AddStringAttachment("Desktop/flowers.jpg","Desktop/flowers.jpg");

if(!$mail->Send())
echo "There has been a mail error sending to " . "order@wasilisa.com" . "<br>";
else echo "thank you for your mail";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();

?>

Do you have any idea about why the image flower.jpg comes empty?
I will appriciate your answer!

OnlyPhp.Com
09-24-2003, 11:01 AM
http://www.hotscripts.com/Detailed/22218.html

I don't know much about it but if you look into this script I'm sure you can find something useful