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 » Tue Jun 18, 2013 10:09 am

Thanks Christoph,

You're right about the need to get the standard form to function correctly first.
I'll grab the latest version of CMS-XHm, try it out and report back :)

Cheers

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

Re: Advancedform_XH

Post by Rkay77 » Tue Jun 18, 2013 10:38 am

Hi Christoph,

No luck :( I performed the upgrade and everything works ok but the standard mailform is still doing the same thing. It says the form has been submitted but no email arrives. The email address set in Settings>Website is very standard and the address I used a mock email address was also very normal...ie both standard ASCII..

:/

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

Re: Advancedform_XH

Post by cmb » Tue Jun 18, 2013 11:18 am

Hmm, it may be best to trim the problem down to some very basic mailing. Take the following code, change the value of $yourMail to your mail address, put it in a file mailtest.php and load that up to the root of your webspace temporarily. Request the file in a browser (http://example.com/mailtest.php). The script tries to send two mails (one without an explicit sender address, and another with an explicit sender. Success resp. failure is reported. Then check, if both mails actually arrive in your inbox.

If only the first one ("First Test") makes it to your inbox, you'll have to check with your provider, how to send mails with an explicit sender address (that may not be allowed on the server).

If none of the mails make it to your inbox, apparently the server is misconfigured. You have to ask your provider again (perhaps sending him the test script).

If at least the second mail makes it to your inbox, the problem is probably CMSimple_XH specific, and we would have to investigate further.

The script:

Code: Select all

<?php

$yourMail = 'webmaster@example.com';

$senderMail = 'user@example.com';

$ok = mail($yourMail, 'First Test', 'First Test');

echo $ok ? 'First Mail sent' : 'First Mail NOT sent', '<br>';

$ok = mail($yourMail, 'Second Test', 'Second Test', 'From: ' . $senderMail);

echo $ok ? 'Second Mail sent' : 'Second Mail NOT sent', '<br>';
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 19, 2013 9:43 am

Neither of the emails were received so I've submitted a request to the host so I'll have to wait until they give me some feedback

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

Re: Advancedform_XH

Post by Rkay77 » Sun Jun 23, 2013 7:24 am

I just got this back from my host..... *now scratching my head*
-----------------------------------------------
Hi Iain

I checked the SMTP logs for the mail you sent with the From: field set and those messages have not shown up which indicates that you are not calling the mail() function correctly.
Please confirm that you are using the mail() function correctly as some header fields may require "\r\n".
There are many PHP based sites on the Server that use PHP to mail out and they are not experiencing any issues so this is not a Server issue on our end.
Refer to the function reference at http://php.net.
-------------------------------------------------

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

Re: Advancedform_XH

Post by cmb » Sun Jun 23, 2013 10:37 am

I'm quite confused, too.

According to http://php.net/manual/en/function.mail.php:
Multiple extra headers should be separated with a CRLF (\r\n).
As there was only 1 additional header, everything should be fine.

You may try again with the following script:

Code: Select all

<?php

$yourMail = 'webmaster@example.com';

$senderMail = 'user@example.com';

$ok = mail($yourMail, 'Test', 'Test', 'From: ' . $senderMail . "\r\n");

echo $ok ? 'Mail sent' : 'Mail NOT sent', '<br>'; 
When I request this script, I get the response "Mail sent". The following message is delivered to the MTA (which is exactly the same without the "\r\n" after the From: header field):

Code: Select all

To: webmaster@example.com
Subject: Test
From: user@example.com

Test
In your case mail() talks directly to an SMTP server, so there's no such message created, but instead appropriate SMTP commands are called. But after all, if mail() returns true, i.e. the script shows "Mail sent", the mail should have been delivered to the MTA, so at least some error should be shown in the MTA's error log.
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: Advancedform_XH

Post by Rkay77 » Sun Jun 23, 2013 12:01 pm

I ran that script and got the 'mail sent' message. no email arrived still :/

I've looked at the php.net site for ideas and tried several of the scripts posted there too but still no luck.

Annoyed at my host insisting that there's nothing wrong at their end. We can't make the script any simpler and direct though so surely it's a server setting???

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

Re: Advancedform_XH

Post by Rkay77 » Sun Jun 23, 2013 12:21 pm

AHhhhh!!!!! one step closer! Now I just need to see if I can get the script to work on the website....might need a hand to ensure I get things in the right now because I can't tell where I should now add the line that needs to be injected..

The line needed was/is

Code: Select all

ini_set("sendmail_from", "webmaster@host.com");
Which needs to be at the very start of the script

My script now looks like

Code: Select all

<?php
ini_set("sendmail_from", "webmaster@host.com");
$yourMail = 'webmaster@host.com';
$senderMail = 'anyemail@test.com';
$ok = mail($yourMail, 'Test', 'Test', 'From: ' . $senderMail . "\r\n");
echo $ok ? 'Mail sent' : 'Mail NOT sent', '<br>'; 
?>

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

Re: Advancedform_XH

Post by cmb » Sun Jun 23, 2013 12:27 pm

The script already is very simple. The only simplification possible is the call of mail() without the explicit "From" header. Did your provider say something about this mail? (it may be possible, that arbitrary "From" headers are not allowed by the MTA).

To further investigate the issue, you can try to talk to the SMTP server directly. This might be possible. The name of the server and its port can be looked up with PHP info (SMTP resp. smtp_port). On http://www.php-faq.de/q-mail-windows.html a script is given which connects directly to the SMTP server and checks for all error conditions (the article is in German, but you may be able to use the script).

Ah, I just have seen your new post. That's a great step forward. If it's actually necessary to set "sendmail_from", you can adjust cmsimple/mailform.php:

Code: Select all

if ($action == 'send')
{ // this is already here; add the following line:
ini_set('sendmail_from', stsl($sender));
This way the built-in mailform may work.
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: Advancedform_XH

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

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..

WAS

Code: Select all

if ($action == 'send')
{
    $msg = $tx['mailform']['sendername'] . ": "
        . stsl($sendername) . "\n"
        . $tx['mailform']['senderphone'] . ": "
        . stsl($senderphone) . "\n\n" . stsl($mailform);
NOW

Code: Select all

if ($action == 'send')
{
ini_set('sendmail_from', stsl($sender));
    $msg = $tx['mailform']['sendername'] . ": "
        . stsl($sendername) . "\n"
        . $tx['mailform']['senderphone'] . ": "
        . stsl($senderphone) . "\n\n" . stsl($mailform);
Now the bigger challenge
How do we go about getting the Advancedform_XH?
I can't work out if should be adjusted at
/plugins/advancedform/
/plugins/advancedform/
/plugins/advancedform/config
/plugins/advancedform/phpmailer

or a combination of places throughout..

Post Reply