Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-01-23 20:12:39

cosmique
New Member
Registered: 2023-01-23
Posts: 4

Sorry, unable to send email?

Hello!

A week ago my TXP websites on GoDaddy refused to send mail via com_connect. The message Sorry, unable to send email? is displayed.

Also in my hosting account I see the warning: Security Notification. Due to a security vulnerability we have temporarily disabled the cPanel mail Horde webmail client until a fix is in place.

I am not sure if it has anything to do with the issue but GoDaddy people say that they are fixing some things and it may take long time.

However, this simple form on other sites works:

<?
if (array_key_exists('InputFullName', $_POST)) {
$to = 'goodman@mail.com';
   $subject = 'Form from '.$_SERVER['HTTP_REFERER'];
   $subject = "=?utf-8?b?". base64_encode($subject) ."?=";
   $message = "Full name: ".$_POST['InputFullName']."\nPhone: ".$_POST['InputPhone']."\nEmail: ".$_POST['InputEmail']."\nFrom Zip: ".$_POST['InputFromZip']."\nTo Zip: ".$_POST['InputToZip']."\nDate of Move: ".$_POST['InputDateofMove']."\nMove Size: ".$_POST['InputMoveSize']."\nOther Remarks: ".$_POST['InputOtherRemarks'];
   $headers = 'Content-type: text/plain; charset="utf-8"';
   $headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Date: ". date('D, d M Y h:i:s O') ."\r\n";
   mail($to, $subject, $message, $headers);
}
?>

What should be changed in the com_connect to make it work (if anything)?

Thanks.

Last edited by cosmique (2023-01-24 00:15:40)

Offline

#2 2023-01-23 23:14:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,460
Website GitHub

Re: Sorry, unable to send email?

Welcome to the forum.

It does sound like GoDaddy are the source of this issue but there are a few things you can try. One is to ensure the ‘envelope send address’ (I forget its actual name) Textpattern preference is set to a return address with the same domain as your host. GoDaddy are notorious for weird mail setups so this might help ease things through.

Although it doesn’t help you right now, in the next version of Txp, we have added third-party SMTP mail integration as well as PHPMailer, and com_connect is ready to use them both. This often helps resolve things because you can use GoDaddy’s SMTP engine directly.

One note though, I would not use that form on a production server. You should at the very least sanitize any user input to avoid injection attacks and mitigate other potential attack vectors. I would wrap any $_POST and $_SERVER with a call to something like the built-in PHP functions strip_tags() and filter_var(). These will encode the characters and filter out harmful content before sending it on, based on the type of input you’re collecting. I appreciate that in this case you’re “only” sending text via the mail() function, but it is still good practice not to trust user input, just in case.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2023-01-24 19:04:22

cosmique
New Member
Registered: 2023-01-23
Posts: 4

Re: Sorry, unable to send email?

Another question.

When I use the simple form on a simple html page (https://experthoustonmovers.com/about-us.html) it sends mails. When I integrated the above simple form into a TXP site https://experthoustonmovers.com/test/ (everything is 100% the same, — .js, .php script ) but the from on TXP site does not sent mails.

Wonder why?
Looks like GoDaddy is not good with TXP?

Offline

#4 2023-01-24 19:21:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,460
Website GitHub

Re: Sorry, unable to send email?

That is odd. They’ll both be using the same mail() function so it shouldn’t have any issue with it. Essentially it’s mostly bypassing Textpattern if you’re embedding PHP via a <txp:php> tag.

Is there anything in any server log files that might give a clue? And if your Txp site is in debugging mode, does it throw any warnings?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2023-01-24 21:04:37

cosmique
New Member
Registered: 2023-01-23
Posts: 4

Re: Sorry, unable to send email?

Bloke wrote #334567:

That is odd. They’ll both be using the same mail() function so it shouldn’t have any issue with it. Essentially it’s mostly bypassing Textpattern if you’re embedding PHP via a <txp:php> tag.

Is there anything in any server log files that might give a clue? And if your Txp site is in debugging mode, does it throw any warnings?

I found out finally that the simple form works from section /test — without slash, not /test/ with slash. Strange.

I realize that it is GoDaddy recent whim, before there was not such a problem.

Debugging does not say much because I make this experiment on a clean TXP page without any txp:codes or plugins.

<!-- Trace summary:
Runtime   : 18.30 ms
Query time: 6.06 ms
Queries   : 10
Memory (*): 1304 kB
-->
<!-- Trace log:
  Time(ms) | Duration | Trace
      1.03 |     0.52 | [PHP includes, stage 1]
      1.60 |     4.05 | [PHP includes, stage 2]
      1.68 |          | 	[Textpattern autoload dir: 'vendors']
      1.71 |          | 	[Textpattern autoload dir: 'lib']
      5.17 |     0.09 | 	[Load: 'vendors/Txp.php']
      5.22 |     0.02 | 		[Load: 'vendors/Textpattern/Container/FactoryInterface.php']
      5.26 |          | 		[Class loaded: 'Txp']
      5.28 |     0.06 | 	[Load: 'vendors/Textpattern/Container/Container.php']
      5.32 |     0.01 | 		[Load: 'vendors/Textpattern/Container/ContainerInterface.php']
      5.34 |          | 		[Class loaded: 'Container']
      5.39 |     0.05 | 	[Load: 'vendors/Textpattern/Tag/Registry.php']
      5.42 |     0.01 | 		[Load: 'vendors/Textpattern/Container/ReusableInterface.php']
      5.44 |          | 		[Class loaded: 'Registry']
      5.76 |     0.19 | [SQL: SELECT name, val FROM txp_prefs WHERE prefs_id = 1 AND user_name = '' ]
      5.97 |          | [Rows: 103]
      6.34 |     0.24 | [SQL: SELECT name, data FROM txp_lang WHERE lang = 'en-us' AND name != '' AND event IN ('public','common') ]
      6.59 |          | [Rows: 449]
      6.88 |     4.49 | [Loading plugins]
      6.90 |     0.27 | 	[SQL: SELECT name, code, version FROM txp_plugin WHERE status = 1 AND type IN (0,1,5) ORDER BY load_order ASC, name ASC ]
      7.17 |          | 	[Rows: 3]
*     7.26 |     2.65 | 	[Loading plugin: 'com_connect' version '4.6.0-beta.2']
      9.92 |     0.28 | 	[Loading plugin: 'pat_speeder' version '0.7.4']
     10.20 |     1.16 | 	[Loading plugin: 'rah_sitemap' version '1.2']
     11.41 |     0.01 | [Callback_event: 'pretext', step='', pre='0']
     11.75 |     0.64 | [SQL: SELECT ID, Section FROM textpattern WHERE url_title = 'test' AND Status >= 4 LIMIT 1 ]
     12.40 |          | [Rows: 0]
     12.45 |     0.64 | [SQL: SELECT name FROM txp_section WHERE name = 'test' LIMIT 1 ]
     13.10 |          | [Rows: 1]
     13.19 |     0.45 | [SQL: SELECT page, css FROM txp_section WHERE name = 'test' LIMIT 1 ]
     13.64 |          | [Rows: 1]
     13.67 |     0.01 | [Callback_event: 'pretext_end', step='', pre='0']
     13.70 |     0.00 | [Callback_event: 'log_hit', step='', pre='0']
     13.72 |     0.19 | [Callback_event: 'textpattern', step='', pre='0']
     13.79 |     0.07 | 	[Load: 'vendors/Textpattern/Type/TypeCallable.php']
     13.83 |     0.01 | 		[Load: 'vendors/Textpattern/Type/TypeInterface.php']
     13.85 |          | 		[Class loaded: 'TypeCallable']
     13.89 |     0.02 | 		[Call function: 'rah_sitemap']
     13.95 |     0.71 | [SQL: SELECT user_html FROM txp_page WHERE name = 'test' ]
     14.66 |          | [Rows: 1]
     14.67 |          | [Page: 'test']
     14.95 |     1.45 | <txp:output_form form="expert_dtd_test" />
     15.07 |     0.81 | 	[SQL: SELECT Form FROM txp_form WHERE name = 'expert_dtd_test' ]
     15.89 |          | 	[Rows: 1]
     15.90 |          | 	[Form: 'expert_dtd_test']
     15.90 |          | 	[Nesting forms: 'expert_dtd_test']
     15.97 |     0.36 | 	<txp:meta_description />
     16.00 |     0.32 | 		[SQL: SELECT description FROM txp_section WHERE name = 'test' ]
     16.32 |          | 		[Rows: 1]
     16.34 |     0.01 | 	<txp:site_url />
     16.35 |     0.01 | 	<txp:site_url />
     16.36 |     0.00 | 	<txp:site_url />
     16.37 |     0.00 | 	<txp:site_url />
     16.37 |     0.00 | 	<txp:site_url />
     16.38 |     0.00 | 	<txp:site_url />
     16.39 |     0.00 | 	<txp:site_url />
     16.40 |     1.83 | <txp:output_form form="expert_footer_test" />
     16.43 |     1.78 | 	[SQL: SELECT Form FROM txp_form WHERE name = 'expert_footer_test' ]
     18.21 |          | 	[Rows: 1]
     18.22 |          | 	[Form: 'expert_footer_test']
     18.22 |          | 	[Nesting forms: 'expert_footer_test']
     18.24 |          | [ ~~~ secondpass ~~~ ]
     18.29 |     0.00 | [Callback_event: 'textpattern_end', step='', pre='0']
-->
<!-- Query log:
Duration | Query
    0.19 | [SQL: SELECT name, val FROM txp_prefs WHERE prefs_id = 1 AND user_name = '' ]
    0.24 | [SQL: SELECT name, data FROM txp_lang WHERE lang = 'en-us' AND name != '' AND event IN ('public','common') ]
    0.27 | [SQL: SELECT name, code, version FROM txp_plugin WHERE status = 1 AND type IN (0,1,5) ORDER BY load_order ASC, name ASC ]
    0.64 | [SQL: SELECT ID, Section FROM textpattern WHERE url_title = 'test' AND Status >= 4 LIMIT 1 ]
    0.64 | [SQL: SELECT name FROM txp_section WHERE name = 'test' LIMIT 1 ]
    0.45 | [SQL: SELECT page, css FROM txp_section WHERE name = 'test' LIMIT 1 ]
    0.71 | [SQL: SELECT user_html FROM txp_page WHERE name = 'test' ]
    0.81 | [SQL: SELECT Form FROM txp_form WHERE name = 'expert_dtd_test' ]
    0.32 | [SQL: SELECT description FROM txp_section WHERE name = 'test' ]
    1.78 | [SQL: SELECT Form FROM txp_form WHERE name = 'expert_footer_test' ]
-->

Offline

#6 2023-01-24 23:12:30

cosmique
New Member
Registered: 2023-01-23
Posts: 4

Re: Sorry, unable to send email?

Well, my solution of slash issue is this.
I put slash before sender.php in .js file referring to php file.

document.getElementById('feedback').onsubmit = function(){
	var field_name =  document.getElementById("InputFullName").value;
	var field_phone =  document.getElementById("InputPhone").value;
	if (field_name.length!=0 && field_phone.length!=0) {
		var http = new XMLHttpRequest();
			  http.open("POST", "/sender.php", true);
			  http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			  http.send("InputFullName=" + this.InputFullName.value + "&InputPhone=" + this.InputPhone.value + "&InputEmail=" + this.InputEmail.value + "&InputFromZip=" + this.InputFromZip.value + "&InputToZip=" + this.InputToZip.value + "&InputDateofMove=" + this.InputDateofMove.value + "&InputMoveSize=" + this.InputMoveSize.value + "&IInputOtherRemarks=" + this.InputOtherRemarks.value);
			  http.onreadystatechange = function() {
				if (http.readyState == 4 && http.status == 200) {
				  $('.alert-success').show().delay(5000).fadeOut(1000);
				  $('.alert-danger').hide();
				  $('#feedback').trigger( 'reset' );
				}
			  }
			  http.onerror = function() {				
			  }
			  return false;
	}
	else {
		$('.alert-danger').show();
		$('.alert-success').hide();
		return false;
	}
}

Com_connect still does not work on GoDaddy. I use this .js + php form temporarily.

Offline

Board footer

Powered by FluxBB