Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-04-20 13:57:43

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Hi

I just noticed that some email admin sent using mem_self_register are not arriving, i first thought it was a spam problem but noticed that it s not the case, i tryed the code below on an article:

<txp:php>
     $to      = 'info@xxxx.com';
     $subject = 'le sujet';
     $message = 'Bonjour !';
     $headers = 'From: info@xxx.com' . "\r\n" .
     'Reply-To: info@xxx.com' . "\r\n" .
     'X-Mailer: PHP/' . phpversion();
     mail($to, $subject, $message, $headers);
</txp:php>

it s not working but using txpMail instead of mail worked!

I also tested a simple php file in the same server using the forst code outside textpattern and it works!

Has the new txp version has disabled mail function ?

Thanks in advance.

More info : I have com_connect installed there and it works as expected even using mail function!

(Textile edit)

Last edited by uli (2020-04-20 14:11:24)

Offline

#2 2020-04-21 18:50:20

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

When things are strange and havent the patience to see why, i decided to change the code and used another one to send email :

try {
			$message = Txp::get('\Textpattern\Mail\Compose')
					->from('admin@xxx.xx', 'Xxx')
					->to($to)
					->subject($subject)
					->body($msg);
			$message->replyTo('admin@xxx.xx');
			$message->bcc('info@xxx.xx');
			$message->send();
	} catch (\Textpattern\Mail\Exception $e) {
			return false;
	}
	return true;

And this one works.

Thanks anyway for people that took the time to read the message.

Offline

#3 2020-04-21 20:21:11

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

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Glad you got it sorted.

My guess – and it is a guess – is that it’s down to the headers that are/aren’t set. These may lead to some servers rejecting the message on the grounds it tips their anti-spam measures over the edge. Sometimes it doesn’t take much at all – just a single word or a header they don’t like and BOOM they quarantine or delete it without you ever knowing it’s been sent. It could be the content of the X-Mailer header, who knows.


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

#4 2020-04-22 05:31:20

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Hi Stef,
Been in a shated hosting, there is not a lot things to do to debug this kind of strange behavior, it is quicker to find a turn around.
Stay safe.

Offline

#5 2020-12-30 22:35:55

kirito
Member
From: Italy
Registered: 2017-01-10
Posts: 34

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Dragondz wrote #322664:

When things are strange and havent the patience to see why, i decided to change the code and used another one to send email :

try {...

And this one works.

Thanks anyway for people that took the time to read the message.

Hello Drangondz, could you explain more in the details what you’ve done here? I’m having a problem with mem_self_register not sending e-mails on new hosting, so this could be a great help to me. I’m trying to make mck_login work, also, but my knowledge of php and of textpattern global mechanisms is not enough: forum.textpattern.com/viewtopic.php?id=51309. Thanks in advance!

Offline

#6 2020-12-31 10:46:33

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

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

kirito wrote #327904:

I’m having a problem with mem_self_register not sending e-mails on new hosting

This is unfortunately common. In the next version of Textpattern we’re building in support for sending emails via third-party SMTP providers. In the meantime, you might like to check out my forks of mem_form and mem_self_register. These versions support PHPMailer, which will likely help.

If you want to take advantage of PHPMailer, you’ll need to download it and drop the contents of their ‘src’ directory into a textpattern/vendors/PHPMailer/PHPMailer/ directory on your server. Or install 4.9.0-dev from our GitHub repo which already has it bundled ready for use.

At the moment (because the prefs aren’t wired up to the UI yet) you’ll need to define them manually in your MySQL client of choice. So you’ll need to define these four prefs if you want to send mail via another provider:

  • smtp_host
  • smtp_user
  • smtp_pass
  • smtp_port

Shout if you need any assistance. The plugins aren’t ‘compiled’ yet but you can upload the .php template files directly into your Admin>Plugins panel on recent Textpattern versions via the Browse… button.

EDIT: correct path for installation.

Last edited by Bloke (2021-02-14 22:29:00)


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

#7 2020-12-31 12:53:34

kirito
Member
From: Italy
Registered: 2017-01-10
Posts: 34

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Bloke wrote #327920:

This is unfortunately common. In the next version of Textpattern we’re building in support for sending emails via third-party SMTP providers. In the meantime, you might like to check out my forks of mem_form and mem_self_register. These versions support PHPMailer, which will likely help.

Bloke: I love you, but I don’t understand what should I do. I installed your forked plugins, copied PHPMailer and defined the prefs in the database, but e-mails are not sent :(
Don’t you have a working version of mck_login? :D Registering and self change password (when logged in) are ok, but the reset password feature doesn’t send the second e-mail (with the new password) when you paste the link sent with the first one.

Last edited by kirito (2020-12-31 12:53:56)

Offline

#8 2020-12-31 13:09:25

kirito
Member
From: Italy
Registered: 2017-01-10
Posts: 34

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Bloke, a comma is missing at line 1223 of your mem_form.

Offline

#9 2020-12-31 13:10:58

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

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

If you’re using mck_login for this functionality then the mem_* plugins won’t help. I don’t have a copy of mck_login unfortunately. I believe it’s not been updated since the Txp 4.7 changes, so is still using the old mechanism of sending out the password in plaintext.

What it should be doing is using the newer methods to send out a password reset link which people click to set a new password. Txp then takes care of sending out further notices such as “your password has been changed”.

The plugin probably just needs patching slightly. We haven’t added it to our Plugins repo yet. If you could please send it to me, I’ll see if I can figure out how to patch it.


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

#10 2020-12-31 13:14:27

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

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

kirito wrote #327929:

Bloke, a comma is missing at line 1223 of your mem_form.

Oops, patched. Thanks.


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

#11 2020-12-31 13:39:17

kirito
Member
From: Italy
Registered: 2017-01-10
Posts: 34

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

Bloke wrote #327930:

If you’re using mck_login for this functionality then the mem_* plugins won’t help. I don’t have a copy of mck_login unfortunately. I believe it’s not been updated since the Txp 4.7 changes, so is still using the old mechanism of sending out the password in plaintext.

What it should be doing is using the newer methods to send out a password reset link which people click to set a new password. Txp then takes care of sending out further notices such as “your password has been changed”.

I was using mem_* on a blog with 4.6 on altervista and was working for a couple of years. Now I’m moving on OVH and trying mck_login because mem_* doesn’t work for me… mck_login is quite there, it works except for the reset password procedure: it sends a link, but you click the link, it opens the home page and nothing happens.

The plugin probably just needs patching slightly. We haven’t added it to our Plugins repo yet. If you could please send it to me, I’ll see if I can figure out how to patch it.

I would be happy to do what you ask. Do you mean this repo ? How can I upload a plugin there? Anyway, I have a fork of it on github. I’ve changed nothing, forked just to be sure it doesn’t get lost. github.com/gas-kirito/mck_login
If you could patch it would be amazing!

Offline

#12 2020-12-31 13:55:51

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

Re: Textpattern 4.7 php 7.1 mail function not working[SOLVED]

kirito wrote #327937:

Do you mean this repo ?

Yes. If you want to contribute there, nominate a plugin or simply open a PR against the repo to add the JSON file(s) of the plugins.

I have a fork of it on github.

I’ll see if I can patch it there and offer a PR.


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

Board footer

Powered by FluxBB