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,346
Website

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,346
Website

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: 9,328
Website

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,346
Website

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

Board footer

Powered by FluxBB