Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-10 05:16:16

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Adding an -f Switch So That Email Generated by TXP has a Full Header.

I use Mosso to host a handful of TXP driven sites. A few days ago everything was fine but earlier today I discovered that email being generated by TXP, such as the new user log in / password messages were not getting through in an acceptable time scale. There was a 6 or 8 hour delay.

When I contacted Mosso Support, the guy there explained that “We secured our relays a bit recently and require the use of a -f switch to display full headers. If you don’t use it, [the message] waits in queue to be manually released and can take days. It’s an anti-spam measure.

He provided this PHP script which generates a test message to test PHP mail functionality and shows the use of the -f switch in the third and last but one lines.

<?
$headers = 'From: webmaster@example.com';
mail('nobody@example.com', 'Test email using PHP', 'This is a test email message', $headers, '-fwebmaster@example.com');
?>

 <?php
$to = 'nobody@example.com';
$subject = 'Test email using PHP';
$message = 'This is a test email message';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers, '-fwebmaster@example.com');
?>

I admit that I don’t know how to distinguish a full email header from a less than full email header and so can’t be sure that TXP isn’t producing the former but it seems to add up. What can we do to force the -f switch in TXP? Is there a line that can be added to config.php to do this, for instance?

It seems possible that email from forms (zem_contact_reborn), and a bunch of other key plug-ins that generate email will be similarly affected.

Very many thanks.

Joe

Last edited by joebaich (2008-07-20 06:09:15)

Offline

#2 2008-07-10 08:36:27

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Two questions:
Does the address given to the -f switch have to be the same one as the one in the From: header or is the only requirement that the -f switch is a valid email address?
Must the the address given to the -f switch be within your own domain or can it be any valid email address?

Offline

#3 2008-07-10 14:44:53

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Ruud,

Thank you for your rapid response.

I believe that the answer to your first question is that any Email address that is valid on Mosso can be given to the -f switch and to the second that the email address can belong to any valid domain.

Profound thanks for your interest and advice.

Joe

Last edited by joebaich (2008-07-20 06:06:59)

Offline

#4 2008-08-24 16:51:39

Igor
New Member
Registered: 2008-08-24
Posts: 3

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

I think I might have found the solution for Mosso (at least it’s working for me) and I thought I should put it up here for anybody else that runs into this issue.

The -f switch needs to be added to the zem_contact_reborn plug in. It seems that TextPattern uses this plug in to generate and send out e-mail. You need to edit the plug in and find the line:

if (mail($to, $subject, $msg, $headers))

You can do this by simply searching for “mail(“, it will be the first hit in the search. At the end of this line add ‘-f$from’ so that the line looks like:

if (mail($to, $subject, $msg, $headers, ‘-f$from’))

Voila, mail doesn’t take hours to get delivered on Mosso.

Offline

#5 2008-08-24 21:33:33

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Thanks for that Igor! See the post here for more information of ‘-f switch’ hacks for TXP and Plugins that use php mail().

Offline

#6 2008-09-01 10:04:27

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

TextPattern uses this plug in to generate and send out e-mail.

No it doesn’t. It is, however, a plugin that allows you to have form emails, which Textpattern does not natively support. So yes, you may need to adjust it, but you would still also have to adjust Textpattern itself for the emails it sends.

Offline

#7 2008-09-01 15:49:49

Igor
New Member
Registered: 2008-08-24
Posts: 3

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Hmm, where is the Textpattern function then so that we could add it there as well?

Offline

#8 2008-09-01 15:54:30

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

The diff is here, will go into TXP 4.0.7

Offline

#9 2008-09-01 17:08:26

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Igor wrote

Hmm, where is the Textpattern function then so that we could add it there as well?

joebaich wrote:

See the post here for more information of ‘-f switch’ hacks for TXP and Plugins that use php mail().

Igor,

Until 4.0.7, follow the link in my previous post. It answers your question.

Offline

#10 2008-09-01 17:10:14

Igor
New Member
Registered: 2008-08-24
Posts: 3

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

Thanks guys for taking care of this. Do you guys have a date in mind for 4.0.7?

Offline

#11 2008-09-04 12:46:11

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Adding an -f Switch So That Email Generated by TXP has a Full Header.

When you pull the toothpick out and there’s no gooeyness left inside.

:D

Offline

Board footer

Powered by FluxBB