Noob Q: Installing Swift Mailer

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
xpt
Forum Newbie
Posts: 23
Joined: Tue Feb 20, 2007 1:00 pm

Noob Q: Installing Swift Mailer

Post by xpt »

Installing Swift Mailer is exremely easy, as with most PHP Libraries.
The problem is I'm new to php and have only install php modules the pear way, seems that you can put the extracted 'lib' directory anywhere. So what is the recommended location that I should put the lib dir, so that php can see it?

Can I install the swiftmailer the pear way? If so, how?

I'm using FC5 currently.

thanks
dillion
Forum Commoner
Posts: 56
Joined: Thu Feb 15, 2007 8:32 am

Post by dillion »

In theory you could put the lib folder anywhere in your web root folder but I usually put them into a "class" or "includes" folder where other classes reside (e.g. functions, validation, connection strings, etc.).

Once you have copied the files to a folder, you then need to load them into a page (aka parent file) that will use the emailer by doing either a require or include:

Code: Select all

require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
// and any other plugins, etc. that you need
The path specified above assumes that your parent file is in a root folder.

Btw, sorry I am not too familar with PEAR except for Excel exporter facility.
audrey
Forum Newbie
Posts: 12
Joined: Sat Mar 03, 2007 2:19 pm

toss it in the PEAR directory

Post by audrey »

The PEAR repository is already in the include path, so you can unpack Swift in there.

On my setup (linux):

# change to wherever your PEAR dir is
cd /usr/local/php/lib/php

# unpack the tarball from wherever you downloaded it to into this dir
tar xzvf ~/downloads/Swift-3.0.1-php5.tar.gz

# create a soft link named "Swift"
ln -s Swift-3.0.1-php5 Swift

Now, in your script:

require_once 'Swift/lib/Swift.php';

etc. The same principles apply for Windows, although i'm not familiar with the specifics of that OS.
Post Reply