Loading...
 
Features / Usability

Features / Usability


Errors in share.tpl preventing "Share this page" from working?

posts: 2

Greetings!

I think I have found a bug in the file ../templates/mail/share.tpl. But I have so little knowledge of the tech involved in Tikiwiki that I'm not certain, so I thought I'd pass it on and either learn something or help someone.

First, my installation is Tikiwiki 6.2, installed on a Windows 2003 Server under XAMPP (Apache Friends v1.7.3). Install is pretty much stock.

Tikiwiki's email settings are to use STMP to my internal mail server, port 25, no authentication. This server is an old Linux Redhat box running Qmail.

I was having problems with email functions:

- sending an email from the test box in General -> General Settings -> Mail section works
- sending an email for registration of new users doesn't work
- sending a "Share this page" email doesn't work.

By examining the logs of my mail server, I could see it was complaining about "Bare line feeds" when I was sending the "Share this page" email. Qmail SMTP is picky about this and won't accept emails with a bare line feed.

After some browsing around I found ../templates/mail/share.tpl, and examining it shows what might be the problem:

{if !empty($comment)}
{$comment}
{else}
{tr}Look at this link:{/tr}
{/if}
{$url_for_friend|replace:' ':'+'}

{$name|username}
{$email}


The blank line (#7) is really a linefeed (0x0a), and this is what Qmail is objecting about. So I added a hyphen to this line:

{if !empty($comment)}
{$comment}
{else}
{tr}Look at this link:{/tr}
{/if}
{$url_for_friend|replace:' ':'+'}
-
{$name|username}
{$email}


and now I can use the "Share this page" feature.

Now, I wonder if there are similar problems in other templates that are causing my other problems?

Note that this might be limited to people using Qmail; as I said, it's pretty picky about this issue. Changing the setting for CR LF vs. LF in the General settings page doesn't fix this.

Hope this helps someone.

posts: 2
Marc Laporte wrote:


Marc,

Further looking about in the templates leads me to think that changing the templates is the wrong way to fix this. Seems that there are many templates with lines that are just a single LF.

So I dug more and added a simple "replace all bare LFs with CRLF" the following to ../lib/messu/messulib.php:

$mail = str_replace("\r\n","\n",$mail); // textCRLF -> LF
$mail = str_replace("\r","\n",$mail); // CR -> LF
$mail = str_replace("\n","\r\n",$mail); // LF -> CRLF

This is my first ever PHP code, so I hope it isn't too messed up or ugly... time to start learning PHP.

These seems to work for all email functions, since I suspect messulib.php is used everywhere an email function os required.

Something I couldn't figure out... there is a setting in the General Settings -> Email page for setting the line endings to either "LF" or "CRLF". But this didn't solve my problem. I was hoping to find that variable and either use it or fix it.. Does anyone know what that variable is?

As I mentioned, I are not a PHP programmer. So I'm hoping this fix is correct. Obviously, no warranty expressed or implied. For all I know I have a broken mail server and this fix would be done at the mail server.


Best Regards!


posts: 1

I can verify this problem. On my tiki 6.02 installation I can send out a test email fine but the password reset email fails. It appears my smtp server is only accepting CRLFs and not LFs by themselves. I say "appears" because I do not have admin access to the mail server and so I cannot read the logs. Setting the mail end of line to "CRLF" in General Preferences does not seem to do the trick.

Instead what I have done is added the following to tiki-remind_password.php

$body = stripslashes($smarty->fetchLang($languageEmail, 'mail/password_reminder.tpl'));
$mail->setText(str_replace("\n","\r\n",$body));

Right above the following block (Aprox line 89)
if (!$mail->send'email'" class="wiki wikinew text-danger tips array">$_REQUEST'email') {
$smarty->assign('msg', tra("The mail can't be sent. Contact the administrator"));
$smarty->display("error.tpl");
die;
}

This should replace the line feeds that the General Preference's setting should Have taken care of.