[SOLVED] Cannot set attribute 'name' error

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
hergy80
Forum Newbie
Posts: 2
Joined: Fri Jun 01, 2007 11:31 am

[SOLVED] Cannot set attribute 'name' error

Post by hergy80 »

When we try to embed an image into an html doc we keep getting a MimeException:

Cannot set attribute 'name' for header 'Content-Type' as the header does not exist.

A snippit of our code is:

Code: Select all

$message = new Swift_Message($msg->Subject);
...

$EmbeddedFile = new Swift_Message_EmbeddedFile($attachInfo['Data'], $attachInfo['Name'], $attachInfo['Type'], $attachInfo['CID']);

$src = $message->attach($EmbeddedFile);
We're using the latest build on the download page. Any help would be appreciated!

Thanks.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmm, what does this show:

Code: Select all

echo "Data length is: " . strlen($attachInfo["Data"]) . "<br />";
echo "Name contains:";
var_dump($attachInfo["Name"]);
echo "Type contains:";
var_dump($attachInfo["Type"]);
echo "CID conains:";
var_dump($attachInfo["CID"]);

$EmbeddedFile = new Swift_Message_EmbeddedFile($attachInfo['Data'], $attachInfo['Name'], $attachInfo['Type'], $attachInfo['CID']);
It's almost like NULL is being passed for the Type parameter (which would basically be 'undefined index "Type"' if error reporting was set to show notices).
hergy80
Forum Newbie
Posts: 2
Joined: Fri Jun 01, 2007 11:31 am

Post by hergy80 »

Your were right. The $attachInfo is populated from a class' array that didn't have the keys setup properly. Thanks for your quick response and I must say I'm very impressed with Swift Mailer thus far!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

8)
Post Reply