Jump to content

Script to receive images as attachments


RON_ron

Recommended Posts

What am I doing wrong here? or is it perfect??

 

<?PHP

$to = "[email protected]";

 

$subject = "$subject";

$headers = "From:" .$email."\r\n";

$headers .= "Bcc: $email\r\n";

$message = "Name: " . $thename;

 

$file_array = array(0=>array('file'=>'http://webpath/Kline.jpg',

'mimetype'=>'image/jpeg',

'filename'=>'Kline.jpg'));

 

$sentOk = mail("$to",$subject,$message,$headers);

 

echo $_POST["message"];

echo "sentOk=" . $sentOk;

Personally I think that mail can be such a finicky thing you should let an API handle it. Personally I use PhpMailer: http://phpmailer.worxware.com/index.php?pg=phpmailer

 

For attachments its quiet simple.

 

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->AddAddress("[email protected]", "John Doe");

$mail->From     = "[email protected]";
$mail->AddAddress("[email protected]");

$mail->Subject  = "First PHPMailer Message";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";

$mail->AddAttachment("images/phpmailer.gif");

if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent.';
}

?>

My submit form is in FLASH. I'm using this PHP to catch the data + the images (as attachments) in to my mail. Data capturing works pretty well. So I tried adding only the line AddAttachemnt. But there's some error in it.  :confused: What's wrong here? I need the images tobe as attachemnts.

 

Current code

<?PHP

$to = "[email protected]";

 

$subject = "subject";

$headers = "From:" .$email."\r\n";

$headers .= "Bcc: $email\r\n";

AddAttachment("images/Kline.jpg");

$message = "Name: " . $thename; 

 

echo "sentOk=" . $sentOk;

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.