# Has anyone used Formail?



## aconite (Feb 1, 2006)

Hi,

I have been getting formail script errors: The following error occurred in FormMail : You must set either TEMPLATEDIR or TEMPLATEURL in formmail.php before you can specify templates in your forms, I am not sure how to fix this, they are from [email protected]. Any help appreciated


----------



## tomdkat (May 6, 2006)

Yep, you can search this forum for previous discussion on FormMail. 

The message is self explanatory. Read this information on using templates and then post any outstanding questions you might have.

Peace...


----------



## aconite (Feb 1, 2006)

I have read the information on using templates and followed the steps but am getting formail script errors like this one:
The following error occurred in FormMail :
Failed to open template
"photorestorationexpert.co.uk/public_html/fmtemplate/plain.txt" :
fopen(photorestorationexpert.co.uk/public_html/fmtemplate/plain.txt) [function.fopen]: failed to open stream: No such file or
directory
Even if I took out public_html, it is still the same message
This is the code in the form:

thanks


----------



## tomdkat (May 6, 2006)

This looks like a simple configuration issue. I've sent you a PM. 

Peace...


----------



## tomdkat (May 6, 2006)

Ok, per the template dir instructions you need to specify the *full path* to your template directory. The setting in $TEMPLATEDIR in your FormMail script is a relative path to the template directory. You will need to find out from your website host, or maybe from cPanel (or the equivalent) if your host provides such a tool, what the FULL path is to your website directory on the server.

For example, the full path to your website directory might be "/home/aconite/public_html" or something like that. Once you find out the full path to your website directory, you should be able to prepend it to your current $TEMPLATEDIR setting.

Peace...


----------



## Sequal7 (Apr 15, 2001)

I also doubt that your templates folder is correct;
photorestorationexpert.co.uk/*public_html/fmtemplate/*plain.txt and have you created and uploaded to your server the plain.txt file in your public_html/fmtemplate folder and made it writeable?

If you want to find a full path, create a phpinfo.php file;

```
<? phpinfo() ?>
```
and place it in the directory where your *templates* reside. Execute the file (http://yoursite.com/path/to/phpinfo.php)

Search the info page for the line: 
SCRIPT_FILENAME (will be under your apache environment heading)
it will display the path to the file (in bold)
*D:/Inetpub/wwwroot/username/foldername/subfoldername/*info.php

This is what you need to place in the code

```
$TEMPLATEDIR = "D:/Inetpub/wwwroot/username/foldername/subfoldername/fmtemplates"; // directory for template files; ...
```


----------



## tomdkat (May 6, 2006)

Sequal7 said:


> have you created and uploaded to your server the plain.txt file in your public_html/fmtemplate folder and made it writeable?


Why would it need to be writeable?

Peace...


----------



## Sequal7 (Apr 15, 2001)

Ooops. my mistake good catch.
I thought the form was posting to a text file, didn't read the templates link that the variables come from the text file. It is *not* necessary.


----------



## tomdkat (May 6, 2006)

Gotcha.  That's the other thread you're thinking of. 

Peace...


----------



## aconite (Feb 1, 2006)

thanks sequal7 and tomdkat, will try it out


----------



## aconite (Feb 1, 2006)

sequal7,

I put the phpinfo.php file in the fmtemplate folder,this is where the plain.txt template resides, to find the full path to the $templatedir but still came up with an error message:
The following error occurred in FormMail :
Failed to open template "home/photores/public_html/fmtemplate/plain.txt" :
fopen(home/photores/public_html/fmtemplate/plain.txt) [function.fopen]: failed to open stream: No such file or
directory
I looked for the SCRIPT_FILENAME under the 'ENVIRONMENT' section of the phpinfo page and it came up with home/photores/public_html/fmtemplate, but it was not displayed in bold
I also read through the Templates for Plain Emails on the Tectite Formail website.

thanks once again


----------



## Sequal7 (Apr 15, 2001)

Hello, it appears that your directory is correct, I meant that you wanted to look for the bold part i my post, not that it would be bold in your script 

Now, have you created and uploaded the plain.txt file to that directory?
home/photores/public_html/fmtemplate/
If you have, can you post or PM me the code you put into it?

If you have, perhaps you need to change the permissions to read/execute (if not already set)


----------



## tomdkat (May 6, 2006)

aconite said:


> I put the phpinfo.php file in the fmtemplate folder,this is where the plain.txt template resides, to find the full path to the $templatedir but still came up with an error message:
> The following error occurred in FormMail :
> Failed to open template "home/photores/public_html/fmtemplate/plain.txt" :
> fopen(home/photores/public_html/fmtemplate/plain.txt) [function.fopen]: failed to open stream: No such file or
> directory


Try this setting in your FormMail script:

$TEMPLATEDIR = "*/*home/photores/public_html/fmtemplate";

See what that does. Don't forget the leading forward slash. 

Peace...


----------



## aconite (Feb 1, 2006)

tomdkat,

thanks very much, formail went through without any error messages, it was the / (forward slash) that was the problem


----------



## tomdkat (May 6, 2006)

Great! Now that it appears to be working, try sending yourself a form with missing required fields to make sure the error reporting is also working. FormMail is supposed to send an e-mail message to the account you configured in the script when it detects an error in the form that was submitted.

If you are getting your FormMail error e-mail messages, you should be all set! 

Peace...


----------

