Error writing some custom PHP (is 'require' allowed?)
Posted: Tue Mar 20, 2007 2:56 pm
I am going to creating a custom form using phpmailer that will send out an email to the appropriate office selected in a drop-down.
Now I went into config.php and set use_smarty_php_tags = true; and then got started on my template that will hold the form. Here is my code:
Now it seems that as soone as it hits "require("/phpmailer/class.phpmailer.php");" nothing happens. For example I do not see the text "Test2" that I entered just to see where I was having the problem, no email ends up getting sent but no error or confirmation gets written to the screen either.
I'm wondering, am I allowed to use require inside of a smarty template file? Also, is this the best way to do this or should I be going about this another way?
Many thanks in advance.
Now I went into config.php and set use_smarty_php_tags = true; and then got started on my template that will hold the form. Here is my code:
Code: Select all
{php}
echo 'Test1';
############## EMAIL LEADER ######################
// generate email
require("/phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
echo 'Test2';
$mail->From = 'test@test.com';
$mail->FromName = 'Test';
// FOR TESTING
$mail->AddAddress("test@test.com", "Test");
$mail->Subject = "Test request";
// FOR TESTING
$mail->Body = "\nTesting a request from the web site.";
if(!$mail->Send())
{
echo "Message could not be sent. Please contact <a href=\"mailto:test@test.com\">Test</a>. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
// comment out below line for live version
echo "Message has been sent";
{/php}
I'm wondering, am I allowed to use require inside of a smarty template file? Also, is this the best way to do this or should I be going about this another way?
Many thanks in advance.