Re: [fw-general] Problem attaching Zend_Mail

2009-08-20 Thread till
2009/8/20 José de Menezes Soares Neto :
> 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));

Maybe try using file_get_contents() and debug that fread() really
contains a string.

Sounds like it does not.

Till


Re: [fw-general] Problem attaching Zend_Mail

2009-08-20 Thread José de Menezes Soares Neto
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' => "jose...@gmail.com",
'password' => "mypassword",
'ssl' => "ssl",
'port' => "465"
);

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

$mail = new Zend_Mail();
$mail->setFrom("jose...@gmail.com");
$mail->addTo("z...@detetive.net");
$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 

> 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 
>
> Hello,
>>
>> Anyone knows how to attach a file??
>>
>> Regards,
>>
>> José
>>
>
>


Re: [fw-general] Problem attaching Zend_Mail

2009-08-19 Thread mbneto
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 

> Hello,
>
> Anyone knows how to attach a file??
>
> Regards,
>
> José
>


[fw-general] Problem attaching Zend_Mail

2009-08-19 Thread José de Menezes Soares Neto
Hello,

Anyone knows how to attach a file??

Regards,

José