Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1261 2012-11-26 19:33:48

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

Re: zem_contact_reborn 4.0.3.20

@gallex, edit the plugin, replace “split” with “explode” where you find it in the plugin code. Yeah, I should fix this.

Last edited by ruud (2012-11-26 19:34:00)

Offline

#1262 2012-11-27 08:16:23

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: zem_contact_reborn 4.0.3.20

ruud wrote:

edit the plugin, replace “split” with “explode” where you find it in the plugin code. Yeah, I should fix this.

found it in one place, and it helped. thank’s!

Offline

#1263 2012-11-27 09:18:06

hildebruns
Member
Registered: 2009-03-10
Posts: 35

Re: zem_contact_reborn 4.0.3.20

Hello,

this thread is very long! I haven´t found a solution for my problem. I have a combolist filled with php. It works on site, but in the Mail there is nothing. The PHP select the next five days without Saturday and Sunday.

<txp:zem_contact_select name="rDate" label="Rückruf Datum: *" list='<txp:php>setlocale(LC_ALL, "de_DE", "de_DE@euro", "de_DE.UTF-8", "german");
$days = array();
$i       = 0;
while(count($days) < 6){
    $timestamp = strtotime(date("Y-m-d +$i") . "day" . ($i > 1 ? 's' : ''));   
    if(!in_array(date('w', $timestamp), array(0,6))){
        $days[] = strftime('%A %d.%m.%Y', $timestamp);
    }   
    $i++;
}
echo implode(', ', $days);</txp:php>' required="1"  />

{Edited to add bc. for better code display. – Uli}

Last edited by uli (2012-11-27 12:03:23)

Offline

#1264 2012-11-27 12:04:27

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: zem_contact_reborn 4.0.3.20

Looks to me like an apostrophe problem: read from the left side into your PHP part inside the list value, which you open with a single apostrophe. There are several single ones before the final, closing, one.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#1265 2012-11-27 17:16:07

hildebruns
Member
Registered: 2009-03-10
Posts: 35

Re: zem_contact_reborn 4.0.3.20

Thank you Uli,

that´s it!

Last edited by hildebruns (2012-11-27 17:16:22)

Offline

#1266 2012-12-02 14:01:43

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: zem_contact_reborn 4.0.3.20

ruud wrote:

Try this:

Thanks Ruud – that does the trick!

Offline

#1267 2012-12-05 22:07:08

Manaus
Member
From: Turin, Italy
Registered: 2010-10-22
Posts: 252
Website

Re: zem_contact_reborn 4.0.3.20

Hello,
I need to send a zem contact form through the google smtp. I really didn’t understand why the smtp defined in the php.ini cannot do that, but the sysadmin passed me a php function with the correct data, so that I shoud hook it with zem contact reborn. Sort of mymail = new PhpMailer() etc.

Anyone has any hint on how to do that?

Thank you very much.

Offline

#1268 2012-12-05 22:23:06

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

Re: zem_contact_reborn 4.0.3.20

hint :)

Offline

#1269 2012-12-06 18:35:44

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: zem_contact_reborn 4.0.3.20

Someone code this sucker up. Puh-lese!

I would very much like to send with smtp, as I suspect it will get by spam servers more betta.

Offline

#1270 2012-12-06 19:55:11

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

Re: zem_contact_reborn 4.0.3.20

TXP 4.6 will have a new “send_mail” function (look at recent commits). It’s still buggy (not all headers are encoded properly and the “<address>” style insn’t enforced on the To addresse), but it that function had a call-back option, you could plugin alternate mail methods. That would make it easier to use things like PHPmailer. Easier than patching both TXP and plugins that want to send mail.

Offline

#1271 2012-12-06 19:59:32

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: zem_contact_reborn 4.0.3.20

postmaster?

Offline

#1272 2012-12-06 21:28:04

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: zem_contact_reborn 4.0.3.20

ruud wrote:

TXP 4.6 will have a new “send_mail” function (look at recent commits). It’s still buggy (not all headers are encoded properly and the “<address>” style insn’t enforced on the To addresse), but it that function had a call-back option, you could plugin alternate mail methods. That would make it easier to use things like PHPmailer. Easier than patching both TXP and plugins that want to send mail.

If you don’t mind me asking, what bugs specifically? The basis of the send_email() function is the same as txpMail(), and it does same type of encoding. It’s the same function, but with configurable options meant for sending generic email.

By wrong encoding do you mean multibyte handling (which supposedly is correct as long as Textpattern’s header encoder function works as supposed) or injections? As far as I know, the function does strip out any newlines and validates email addresses – both which should prevent actual injections. One thing it doesn’t do is stripping NULL bytes. Do you mean that?

Adding callback functionality is on my to-do list and so is additional argument for receiver’s name.

Offline

#1273 2012-12-07 14:35:02

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: zem_contact_reborn 4.0.3.20

r4950 introduces ‘mail.handler’ callback event. That even can be used to override the default mail() based sending. If something is attached to the event, the handler(s) are fired instead of the default handler.

Using the event happens similarly to any other callback:

/**
 * Register to 'mail.header' event.
 */

	register_callback('abc_smtp_sender', 'mail.handler');

/**
 * Sets your SMTP server (Gmail) username.
 *
 * Can/should be moved to config.php.
 */

	define('abc_stmp_username', 'yourusername@gmail.com');

/**
 * Sets your SMTP server (Gmail) password.
 *
 * Can/should be moved to config.php.
 */

	define('abc_stmp_password', 'yourpassword');

/**
 * Send emails over SMTP.
 *
 * This function replaces the default mail handler. Basic example
 * that uses PHPMailer for sending emails over Gmail SMTP server.
 *
 * Expects that PHPMailer is installed to 'phpmailer' directory located
 * next to '/textpattern' directory, the same directory where Textpattern
 * was installed to.
 *
 * @param  string $event   The callback event
 * @param  string $step    The callback step
 * @param  array  $data    The raw arguments passed to send_email()
 * @param  string $send_to Encoded receiver
 * @param  string $subject Encoded subject
 * @param  string $body    Encoded body
 * @param  string $headers Encoded headers
 * @return bool   TRUE on success, or FALSE on failure
 */

	function abc_smtp_sender($event, $step, $data, $send_to, $subject, $body, $headers)
	{
		require_once dirname(txpath) . '/phpmailer/class.phpmailer.php';

		extract($data);

		$mail = new PHPMailer();
		$mail->IsSMTP();
		$mail->SMTPAuth = true;
		$mail->SMTPSecure = 'tls';
		$mail->Host = 'smtp.gmail.com';
		$mail->Port = 587;
		$mail->Username = abc_stmp_username;
		$mail->Password = abc_stmp_password;

		$mail->SetFrom($from_address, $from_name);

		if ($reply_address)
		{
			$mail->AddReplyTo($reply_address, $reply_name);
		}

		$mail->Subject = $subject;
		$mail->Body = $body;
		$mail->AddAddress($to_address, $to_name);
		return $mail->Send();
	}

That all is just a basic (untested) example to give the rough idea.

Last edited by Gocom (2012-12-07 14:37:36)

Offline

#1274 2012-12-07 14:56:41

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: zem_contact_reborn 4.0.3.20

So how hard would it be to adapt postmaster to use this function?

Offline

#1275 2012-12-07 19:35:43

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

Re: zem_contact_reborn 4.0.3.20

Gocom wrote:

If you don’t mind me asking, what bugs specifically? The basis of the send_email() function is the same as txpMail(), and it does same type of encoding. It’s the same function, but with configurable options meant for sending generic email.

No problem. I wrote that from memory, so I didn’t have the details then… so, here we go. Not all are bugs.

1. It only allows one “To” address. Accepting multiple recipient addresses is something ZCR and probably Postmaster would need. Ideally “To_address” accepts an array. If so, then “To_name” should do the same. Same applies to the Reply-To address although fewer people will set multiple addresses there.

2. header values aren’t encoded using encode_mailheader():

foreach ($headers as $field => &$value)
{
$value = strip_rn($field.': '.$value);
}

3. And no check is done on the validity of the field names, although arguably, whoever calls this function should check that.

4. To_name, From_name and Reply_name are optional parameters, in the function call they are at the beginning of the parameter list instead of at the end. If you look at the PHP mail function, i’d order them like this:

 send_email($to_address, $subject, $body, $headers = array(), $from_address = '', $reply_address = '', $to_name= '', $from_name = '', $reply_name = '')

5. If to_name is not set, this code below technically correct, but I’ve seen Spamassassing treat this as spam because it really likes the “to” address in “< >” in all cases, even if no name is supplied. Doing so isn’t required per RFC, but certainly valid. You could get rid of the “else” part and trim the result to get rid of the extra space if to_name is empty. Same could be done for reply-to and from:

if ($to_name)
{
$to_name = encode_mailheader(strip_rn($to_name), 'phrase');
$send_to = $to_name.' <'.$to_address.'>';
}
else
{
$send_to = $to_address;
}

6. In the code above, the strip_rn isn’t applied to to_address. Same applies to reply-to and from.

7. This one is funny. I have/had that in ZCR as well. Why is the condition !IS_WIN instead of IS_WIN?

$sep = !IS_WIN ? "\n" : "\r\n";

8. Allow a different “x-mailer” header by doing this only if it isn’t supplied in the headers:

$headers['X-Mailer'] = 'Textpattern';

9. Can we finally drop the ISO-8859-1 support? TXP does UTF-8 every else. If there were mail clients that didn’t support UTF-8 when TXP was released, surely no-one is using them now anymore. The whole utf_decode stuff is really an ugly hack. Is there anyone who really needs this, raise your hand!

10. Is_valid_email() is not future proof. It limits the TLD to 6 characters. PHP has some built in support for this now. It does treat user@localhost type addresses as valid, but it’s not hard to exclude those with a trivial regex (if you want to exclude them at all)

filter_var($email, FILTER_VALIDATE_EMAIL)

By wrong encoding do you mean multibyte handling (which supposedly is correct as long as Textpattern’s header encoder function works as supposed)?

I sure hope it works as supposed. I wrote that one ;)

As far as I know, the function does strip out any newlines and validates email addresses – both which should prevent actual injections. One thing it doesn’t do is stripping NULL bytes. Do you mean that?

I hadn’t actually thought about that one. ZCR strips NULL bytes in both header and body.

Adding callback functionality is on my to-do list

return callback_event('mail.handler', '', 0, $arguments, $send_to, $subject, $body, $headers) !== '';

11. If people want to use the phpmailer add-on, then it’s perhaps easier to pass on unprocessed parameters. Strip_rn and the newline corrections are fine, but phpmailer encodes headers by itself and expects additional headers as an array. It has it’s on methods for adding from/to/reply-to headers, see class.phpmailer

12. Not sure what $arguments does. Perhaps my PHP/TXP knowledge is getting a bit rusty.

Offline

Board footer

Powered by FluxBB