Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#871 2010-09-17 17:22:30
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: zem_contact_reborn 4.0.3.20
Enor wrote:
I posted it already.
I answered it already. Twice ;)
Offline
#872 2010-09-18 21:47:36
- Enor
- Member
- From: London, UK
- Registered: 2010-09-02
- Posts: 26
Re: zem_contact_reborn 4.0.3.20
Thanks guys :) Got it working now.
Offline
#873 2010-09-19 12:18:51
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: zem_contact_reborn 4.0.3.20
Hello, I am trying to alter the plugin so that it works in Webfaction, which doesn’t allow the mail() function. I have taken the advice of a few posts such as this one but I don’t think it works for version 4.2.0
I have successfully used PHP mailer for the txplib_misc.php to send emails from textpattern. I am trying to use it to send mail from ZCR. This is what I have so far:
1) added include_once('/textpattern/lib/custom/class.phpmailer.php'); to the first function in ZCR
2) and I have made modifications similar to this forum post http://forum.webfaction.com/viewtopic.php?pid=18518#p18518
However this is the error that I get: Fatal error: Class ‘PHPMailer’ not found in pathto/textpattern/lib/txplib_misc.php(594) : eval()’d code on line 231
I would really love some help trying to get this to work. Thanks, so much.
Last edited by immarabi (2010-09-19 20:58:48)
Offline
#874 2010-09-19 13:22:32
Re: zem_contact_reborn 4.0.3.20
immarabi wrote:
1) added
include_once('/textpattern/lib/custom/class.phpmailer.php');to the first function in ZCR
Is that path correct or should it be this instead:
/path/to/textpattern/lib/custom/class.phpmailer.php
Offline
#875 2010-09-19 19:51:17
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: zem_contact_reborn 4.0.3.20
Ok, you are right about that. Looks like everything is working now. Since this is my first time editing a plugin by myself, can you just look this over for me and recommend some changes if you think of any. Thank you very much!
I removed this:
if (mail($to, $subject, $msg, $headers))
{
$_POST = array();
if ($copysender and $zem_contact_from)
{
mail(zem_contact_strip($zem_contact_from), $subject, $msg, $headers);
}
and this after it:
else
{
return '<div class="zemThanks" id="zcr'.$zem_contact_form_id.'">' .
($thanks_form ? fetch_form($thanks_form) : $thanks) .
'</div>';
}
}
else
{
$out .= graf(zem_contact_gTxt('mail_sorry'));
}
And I replaced it with this:
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "hostxxxx:25"; // Webfaction SMTP Server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "usernamexxxx"; // Your Webfaction mailbox user
$mail->Password = "passwordxxxx"; // Mailbox password
$mail->From = $zem_contact_from;
$mail->FromName = $zem_contact_from;
$mail->Subject = $subject;
$mail->MsgHTML($msg);
$mail->AddAddress($to);
if(!$mail->Send()) {
echo "<!-- Nasty error : " . $mail->ErrorInfo ." -->\n"; // Debug
$out .= graf(zem_contact_gTxt('mail_sorry'));
} else {
echo "<!-- Email Sended -->\n";
return '<div class="zemThanks" id="zcr'.$zem_contact_form_id.'">' .
($thanks_form ? fetch_form($thanks_form) : $thanks) .
'</div>';
}
// end SMTP mod
Last edited by immarabi (2010-09-19 19:57:06)
Offline
#876 2010-09-19 20:13:08
Re: zem_contact_reborn 4.0.3.20
Add $_POST = array(); just above the ‘return’ statement.
You’ve removed copysender and redirect functionality, which is fine if you don’t need it.
You may also lose some headers that ZCR normally adds, like Content-Type (which sets the charset to UTF-8, while PHPmailser uses iso-8859-1 by default!) and the header that adds the IPnr of the sender.
Also, the $subject you’re using is already encoded. Because PHPMailer does the same, you risk having it encoded twice, which won’t notice until you use characters in your subject that need encoding.
Offline
#877 2010-09-19 20:39:33
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: zem_contact_reborn 4.0.3.20
Thanks. You have been enormously helpful. Just to make sure I understood you correctly, let me post it one more time. If I remove $mail->Subject = $subject; then I get no subject in the email. I am not sure what you mean about having the subject encoded twice and how I can avoid that. I forgot to mention that I also changed this: if (!is_callable('mail')) to if (!is_callable('utf8_encode')), I hope that helps with the Content-type. Here is what I have now:
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "xxx"; // Webfaction SMTP Server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "xxx"; // Your Webfaction mailbox user
$mail->Password = "xxx"; // Mailbox password
$mail->From = $zem_contact_from;
$mail->FromName = $zem_contact_from;
$mail->Subject = $subject;
$mail->MsgHTML($msg);
$mail->AddAddress($to);
if(!$mail->Send()) {
echo "<!-- Nasty error : " . $mail->ErrorInfo ." -->\n"; // Debug
$out .= graf(zem_contact_gTxt('mail_sorry'));
} else {
echo "<!-- Email Sent -->\n";
$_POST = array();
return '<div class="zemThanks" id="zcr'.$zem_contact_form_id.'">' .
($thanks_form ? fetch_form($thanks_form) : $thanks) .
'</div>';
}
Offline
#878 2010-09-19 21:04:03
Re: zem_contact_reborn 4.0.3.20
If you’re using something else than mail(), you can probably change !is_callable('mail') into false so that code block is never executed.
Comment out (or remove) this line to avoid encoding of the subject line by ZCR:
$subject = zem_contact_mailheader($subject, 'text');
And you can probably add a line like this to the other mail-> lines to set the charset:
$mail->CharSet = 'UTF-8';
PS. and remove the two ‘echo’ lines.
Offline
#879 2010-09-19 21:33:56
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: zem_contact_reborn 4.0.3.20
One last question, thank you so much for your time. How do you change !is_callable(‘mail’) into false?
Offline
#880 2010-09-19 21:37:02
Re: zem_contact_reborn 4.0.3.20
Simply replace that part of the plugin code. Literally replace !is_callable('mail') with false (or FALSE or 0).
Last edited by ruud (2010-09-19 21:37:29)
Offline
#881 2010-10-05 14:01:54
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: zem_contact_reborn 4.0.3.20
I’m trying to use zem_contact_reborn to produce a simple contact form using:
<txp:zem_contact to=“my@email-address.com” />
Whenever I try to use it though I keep getting the following error message:
Fatal error: Call to undefined function zem_contact_gTxt() in E:\Inet\ross\textpattern\lib\txplib_misc.php(594) : eval()'d code on line 13
Offline
#882 2010-10-05 14:15:37
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: zem_contact_reborn 4.0.3.20
Did you install zem_contact_lang as well?
Offline
#883 2010-10-05 14:27:49
- Algaris
- Member
- From: England
- Registered: 2006-01-27
- Posts: 608
Re: zem_contact_reborn 4.0.3.20
slaps forehead No, I completely missed the big red text in the help file which said:
This plugin requires a separate language plugin called zem_contact_lang to be installed and activated to work properly.
Thank you for pointing that out.
Offline
#884 2010-10-07 01:03:45
- Rimfya
- Member
- Registered: 2007-11-22
- Posts: 31
Re: zem_contact_reborn 4.0.3.20
Hello.
Awesome plugin. For the first time ever though I’m trying to use ‘send article’. Is there a way to NOT require the user to click a link to show the form? As in, the form is visible when the page loads?
Cheers!
Offline
#885 2010-10-07 09:31:41
Re: zem_contact_reborn 4.0.3.20
Rimfya, put this just above your form and it’ll be visible on page load:
<txp:php>$_GET['zem_contact_send_article']='yes';</txp:php>
Offline