Hi, thanks for your help...

Using Zend_Mail is easy, but I got some error trying to send attachments...
the warning is:

*Warning*: base64_encode() expects parameter 1 to be string, object given in
*C:\www\was\lib\Zend\Mime.php* on line *173

*What it could be?

My code is:

// FILE TO BE ATTACHED

$file       = "myfile.xml";
$filepath   = "files/" . $file;
$file_size  = filesize($file);
$handle     = fopen($file, "r");
$content    = fread($handle, $file_size); fclose($handle);
$content    = chunk_split(base64_encode($content));

// SUBJECT

$subject = "The file is" . $file;

// MESSAGE BODY

$message  = "Hello,\n\n";
$message .= "Your file is attached!\n\n";
$message .= "Filename: $file\n\n";

// SMTP CONNECTION + SENDING EMAIL

$config = array (
    'auth' => 'login',
    'username' => "[email protected]",
    'password' => "mypassword",
    'ssl' => "ssl",
    'port' => "465"
);

$mailTransport = new Zend_Mail_Transport_Smtp("smtp.gmail.com", $config);

$mail = new Zend_Mail();
$mail->setFrom("[email protected]");
$mail->addTo("[email protected]");
$mail->setBodyText($message);
$mail->setSubject($subject);

$at = new Zend_Mime_Part($content); // HERE IS THE LINE WHERE WARNING COMES
FROM.
$at->type        = Zend_Mime::TYPE_OCTETSTREAM;
$at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$at->encoding    = Zend_Mime::ENCODING_BASE64;
$at->filename    = $filename;
$mail->addAttachment($at);

$mail->send($mailTransport);



2009/8/19 mbneto <[email protected]>

> Hi,
>
> from the manual
>
> $mail = new Zend_Mail();
> // build message...
> $mail->createAttachment($someBinaryString);
>
> Where this $somebinaryString can set using 
> *file_get_contents('path-to-real-file')
>
> *
>
>
> 2009/8/19 José de Menezes Soares Neto <[email protected]>
>
> Hello,
>>
>> Anyone knows how to attach a file??
>>
>> Regards,
>>
>> José
>>
>
>

Reply via email to