Using Pear Mail

software development

#1

I’m having the worst time trying to get Pear’s mail module working with my site. I’ve followed the instructions in this wiki article: http://wiki.dreamhost.com/PEAR
But am getting the following error:
Parse error: syntax error, unexpected T_VARIABLE in /home/weightlossthroughyoga/weightlossthroughyoga.com/mail.php on line 26
Which, I assume, means the mail module is not loading correctly.

I’m trying to include Pear Mail using these:

<?php set_include_path("." . PATH_SEPARATOR . ($UserDir = dirname($_SERVER['DOCUMENT_ROOT'])) . "/pear/php" . PATH_SEPARATOR . get_include_path()); include 'Mail.php'; I try and create the instance of Mail with Mail::factory(), with of course my parameters. And my .bash_profile is as follows: umask 002 PS1='[\h]$ ' export PHP_PEAR_PHP_BIN=/usr/local/php5/bin/php export PATH=${HOME}/pear:/usr/local/php5/bin:${PATH} Where am I going wrong? Thanks.

#2

I took a look at your PHP script, and you’ve got a missing semicolon a bit further down in your mailer script. (It’s on the line right before the one mentioned in the error message.)

For those following along at home, the code involved looks something like:

[php]$variable = “blahblahblahblah”
$smtp = Mail::factory(…);[/php]

This causes PHP to throw an error on the second line in the snippet (not the first one!), because it thinks the second line is supposed to be a continuation of the first one, but doesn’t know what to do with the variable $smtp at that point.


#3

Thanks for catching that! It’s always something simple… It got me on the right track, however now it’s not finding another file and throwing the following error:

Warning: include_once(Net/SMTP.php) [function.include-once]: failed to open stream: No such file or directory in /home/weightlossthroughyoga/pear/php/Mail/smtp.php on line 348

Warning: include_once() [function.include]: Failed opening ‘Net/SMTP.php’ for inclusion (include_path=’.:/home/weightlossthroughyoga/pear/php:.:/usr/local/lib/php:/usr/local/php5/lib/pear’) in /home/myusername/pear/php/Mail/smtp.php on line 348

Fatal error: Class ‘Net_SMTP’ not found in /home/myusername/pear/php/Mail/smtp.php on line 349
[hr]
Fixed by running ‘pear install Net_SMTP’. Silly mistake. Again. Hope this helps someone else. Thanks again Andrew.