PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 22, 2018 8:29 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Sep 01, 2009 5:53 pm 
Offline
Forum Newbie

Joined: Tue Sep 01, 2009 5:38 pm
Posts: 2
Hi,

I am fairly new to php and very new to Swift Mailer. My code is below, basically I load an attachment from the database, save it into a directory and then wish to attach it to the email I am creating. The permissions in my attachments directory are 755. I am able to successfully send messages with Swift Mailer but as soon as I try to add an attachment I get the string of errors below. The Swift Mailer version I have is Swift-4.0.4. Any help will be appreciated, I have spent 3 evenings on this and am stumped! :banghead: This is some of the code (just the bits that relate to the mailer and still in test stage).

$file_path = str_replace( $_SERVER['DOCUMENT_ROOT'], "", dirname(realpath($attachment_path)) ) . DIRECTORY_SEPARATOR . filename_safe($row["cl_att_file_name"]);
$file_type = filetype($attachment_path);
$file_name = filename_safe($row["cl_att_file_name"]);

require_once "swift-mailer/lib/swift_required.php";

//Create the message
$message = Swift_Message::newInstance()

//Give the message a subject
->setSubject('Swift Mailer Test')

//Set the From address with an associative array
->setFrom(array('adenjgower@gmail.com' => 'Aden Gower'))

//Set the To addresses with an associative array
->setTo(array('adenjgower@gmail.com' => 'Aden Gower'))

//Give it a body
->setBody('Here is the message itself')

//And optionally an alternative body
->addPart('<q>Here is the message itself</q>', 'text/html')

//Optionally add any attachments
//->attach($attachment)

;

$message->attach(Swift_Attachment::fromPath($file_path, $file_type)->setFilename($file_name));

I get this error:

Fatal error: Uncaught exception 'ReflectionException' with message 'Class Swift_Mime_ContentEncoder_Base64ContentEncoder does not exist' in /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php:287 Stack trace: #0 /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php(287): ReflectionClass->__construct('Swift_Mime_Cont...') #1 /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php(305): Swift_DependencyContainer->_createNewInstance('mime.base64cont...') #2 /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php(117): Swift_DependencyContainer->_createSharedInstance('mime.base64cont...') #3 /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php(355): Swift_DependencyContainer->lookup('mime.base64cont...') #4 /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php(331): Swift_DependencyContainer->_lookupRecursive in /home/conscrip/public_html/concruit/swift-mailer/lib/classes/Swift/DependencyContainer.php on line 287


Top
 Profile  
 
PostPosted: Wed Sep 02, 2009 2:07 pm 
Offline
Forum Newbie

Joined: Tue Sep 01, 2009 5:38 pm
Posts: 2
I've solved this, turned out that there was nothing wrong with my code but one of the swift files had corrupted either from the download to my PC or upload to the server.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group