Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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