Advancedform_XH

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Rkay77
Posts: 16
Joined: Tue Mar 26, 2013 3:27 pm

Re: Advancedform_XH

Post by Rkay77 » Mon Jun 24, 2013 3:40 pm

P.S----- THANKS CHRIS!!! You're AWESOME!!!

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Mon Jun 24, 2013 4:23 pm

Rkay77 wrote:OK, great news that works. so the basic mailform is now working.
I inserted the line and it now looks like this for anyone else who may have this issue..
We may consider adding this to standard CMSimple_XH. However, I'm not sure, if that might fail on other servers. I'll open a discussion in OD.
Rkay77 wrote:How do we go about getting the Advancedform_XH?
The most general solution would be to modify PHPMailer. But it's probably simpler and still sufficient to modify plugins/advancedform/advfrm.php. The mails are sent in advfrm_mail(). Starting with line 863:

Code: Select all

    if ($confirmation) {
    $mail->set('From', $form['to']);
    $mail->set('FromName', $form['to_name']);
    $mail->AddAddress($from, $from_name);
    } else {
    $mail->set('From', $from);
    $mail->set('FromName', $from_name);
    $mail->AddAddress($form['to'], $form['to_name']); 
Change that to:

Code: Select all

    if ($confirmation) {
    $mail->set('From', $form['to']);
    $mail->set('FromName', $form['to_name']);
ini_set('sendmail_from', $form['to']);
    $mail->AddAddress($from, $from_name);
    } else {
    $mail->set('From', $from);
    $mail->set('FromName', $from_name);
ini_set('sendmail_from', $from);
    $mail->AddAddress($form['to'], $form['to_name']); 
Christoph M. Becker – Plugins for CMSimple_XH

Rkay77
Posts: 16
Joined: Tue Mar 26, 2013 3:27 pm

Re: Advancedform_XH

Post by Rkay77 » Tue Jun 25, 2013 11:41 am

Hi Chris,

I made the change but I'm still getting the same error I was when I first tried using AdvancedForm_XH.

"ERROR / WARNING"
Could not instantiate mail function.

This error occurs with and without the suggested code modifcation.
Perhaps the PHPmailer is the one that needs changing afterall??

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Tue Jun 25, 2013 3:46 pm

Hi Iain,

please try the following:

Code: Select all

    if ($confirmation) {
    $mail->set('From', $form['to']);
    $mail->set('FromName', $form['to_name']);
    $mail->set('Sender', $form['to']);
    $mail->AddAddress($from, $from_name);
    } else {
    $mail->set('From', $from);
    $mail->set('FromName', $from_name);
    $mail->set('Sender', $from);
    $mail->AddAddress($form['to'], $form['to_name']);
This might work.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Rkay77
Posts: 16
Joined: Tue Mar 26, 2013 3:27 pm

Re: Advancedform_XH

Post by Rkay77 » Wed Jun 26, 2013 3:34 pm

:( same result

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Wed Jun 26, 2013 6:04 pm

Shoot! I'm somewhat at a loss.

Please enable the debug mode and try sending the mail again while you are logged in. Is there any error reported?

What's your PHP ini setting of safe_mode?
Christoph M. Becker – Plugins for CMSimple_XH

Rkay77
Posts: 16
Joined: Tue Mar 26, 2013 3:27 pm

Re: Advancedform_XH

Post by Rkay77 » Thu Jun 27, 2013 9:05 am

I have debug mode set to 6

logged in and while in admin mode used basic version of contact form and get
---------------------------
ERROR / WARNING

Could not instantiate mail function.
---------------------------

'safe_mode' according to link from within admin of CMS that loads new page says
local 'off'
master 'off'

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Thu Jun 27, 2013 11:38 am

Well, then we'll have to debug. The basic idea is to find the actual parameters that PHPMailer passes to the mail() function. These parameters then could be passed in a minimal stand alone script, similar to our first attempts. From then on we might find the problem, and then we could work back.

So please make the following modifications. In plugins/advancedform/advfrm.php in function advfrm_mail():

Code: Select all

    if ($confirmation) {
    $mail->set('From', $form['to']);
    $mail->set('Sender', $form['to']);
    $mail->set('FromName', $form['to_name']);
    $mail->AddAddress($from, $from_name);
    } else {
    $mail->set('From', $from);
    $mail->set('Sender', $from);
    $mail->set('FromName', $from_name);
    $mail->AddAddress($form['to'], $form['to_name']);
In plugins/advancedform/phpmailer/class.phpmailer.php in function MailSend() replace line 481-483:

Code: Select all

      } else {
        $rt = mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
      }
with the following:

Code: Select all

      } else {
        $subject = $this->EncodeHeader($this->SecureHeader($this->Subject));
        $sendmail_from = ini_get('sendmail_from');
        echo '$to = '; var_export($to); echo ";\n";
        echo '$subject = '; var_export($subject); echo ";\n";
        echo '$body = '; var_export($body); echo ";\n";
        echo '$header = '; var_export($header); echo ";\n";
        echo "\n\n\n\n\n\n\n\n\n\n\n\n\n";
        $rt = mail($to, $subject, $body, $header);
      }
Then use the standard 'Contact' form, and make sure there is no "Thanks" page defined (save the form again).

Then try sending a mail. On top of the browser window there will be some debug output. View the HTML source code of the page (confirm the message that data will be send again). Copy the additional debug code (maybe about 72 lines ending with several linebreaks, until the output of your templates is shown, usually starting with <!DOCTYPE), and paste it to a stand alone PHP script:

Code: Select all

<?php

ini_set('sendmail_from', 'me@example.com');

// paste the debug code here

$rt = mail($to, $subject, $body, $header);

echo $rt ? 'Mail sent' : 'Mail not sent';
When the mail has not been sent from Advancedform, this script is most likely to fail also. But give it a try, to double-check that anyway. Then try to adjust some of the variable's values one by one, and try if the mail can be sent. Maybe there's a problem with $to, and the mail server does not like the notation "Name <mail@address.tld>". You should reduce this to exactly the same value you have passed to ini_set('sendmail_from'), and try sending the mail from the stand alone script again.

Well, I know that's ugly debug work, but I can't see another way to find out, what's "wrong" on your server.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Wed Nov 27, 2013 12:46 am

Hello Community,

I've just released Advancedform_XH 1.0rc1.

Many thanks to all who contributed in the long time since 1pl12 to its development by testing, making suggestions, providing general feedback and translations (johnjdoe did the French and tanavots the Estonian translation).

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 13211
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Advancedform_XH

Post by cmb » Thu Dec 05, 2013 4:39 pm

Hello Community,

I've just released Advancedform_XH 1rc2.

manu has reported a bug, which added an empty option to select lists. This is fixed now -- thanks, manu.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply