Jump to content

Email attachments


AikenDrum

Recommended Posts

Hi freaks and experts

 

I am having a problem sending attachments in an email (PEAR MIME)

 

When I send 3 attachments, everything is fine, but more than 3 cause the page to return blank. The code below has 4 attachments, unless I comment out the 4th attachment, nothing will work !

I'm going crazy here, any help greatly appreciated :-((

 

Code:

 

<?php

require_once('Mail.php');

require_once('Mail/mime.php');

 

$text = 'Text version of email';

// $file = 'lightning.jpg';

$crlf = "\n";

$hdrs = array(

              'From'    => $sender,

              'Subject' => $subject

              );

 

$mime = new Mail_mime($crlf);

 

$mime->setTXTBody($text);

 

// Add first file

// $status = $mime->addAttachment($file, 'image/jpeg');

 

// Add more files

$status = $mime->addAttachment( 'PICT8461.JPG', 'image/jpeg');

$status = $mime->addAttachment( 'PICT8462.JPG', 'image/jpeg');

$status = $mime->addAttachment( 'PICT8463.JPG', 'image/jpeg');

// $status = $mime->addAttachment( 'PICT8464.JPG', 'image/jpeg');

 

if( PEAR::isError( $status ) ) {

echo "<p>addAttachment( ) returned with error ".$status->getMessage()."</p>\n";

}

 

$body = $mime->get();

 

// Call after body has been set from $mime

$hdrs = $mime->headers($hdrs);

 

$mail =& Mail::factory( 'smtp');

$status = $mail->send($recipient, $hdrs, $body);

if( PEAR::isError( $status ) ) {

echo "<p>Error sending mail: ".$status->getMessage()."</p>\n";

exit;

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Test Mail</title>

</head><body>

<h1>Test Mail</h1>

<p>Mail sent!</p>

</body></html>

Link to comment
https://forums.phpfreaks.com/topic/56546-email-attachments/
Share on other sites

Dont use PEAR mail use Zigmoyd Mailer.

Zigmoyd Mailer is written by a Seniour Helper of this Forum.

http://zigmoyd.sourceforge.net/man/mail.php#mail

$ext["attach"] = "atch.txt,test.wav";
$mail = new mail("admin@localhost", "Mail Subject", "Mail Body", $ext);
?>

See this Page for Instruction and Installation

http://zigmoyd.sourceforge.net/man/index.php

Link to comment
https://forums.phpfreaks.com/topic/56546-email-attachments/#findComment-279845
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.