Recent Topics

1 Jan 11, 2008 22:16    

My b2evolution Version: 2.x

I know that there are many posts around with the same problem and the suggestion is usually "contact your host provider", but please look at mine... :)

Nobody can register and get this error, but the contact form works perfect.
I can still send emails from any directory using this code with or without Reply-To and get bool(true)

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

$email = "my@emai.com";
$subject = "welcome";
$message = "welcome message";
$headers = 'From: any@email.org' . "\n" .
'Reply-To: any@email.org' . "\n" .
'X-mailer: php/' . phpversion();

$r = mail($email, $subject, $message, $headers);
var_dump($r);
?>

My host is GoDaddy
In my php.ini

precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

Please, tell me what's wrong with my host or installation. :( [/code]

2 Jan 11, 2008 22:57

Looks like the mail() function is missing in B2evo :?:
Try to add:

$r = mail($to, $subject, $message, $headerstring);
var_dump($r); 


in line 1765 of file /inc/_core/_misc.funcs.php
line 1765 is currently a blank line, line 1766 reads: if( $debug > 1 )
and report back to this topic.

Good luck

3 Jan 11, 2008 23:06

Thank you for getting in.

The output is

Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /.../inc/_core/_misc.funcs.php on line 1766
bool(false)

4 Jan 11, 2008 23:13

if I use contact form I get bool(true)

5 Jan 11, 2008 23:15

The headerstring looks to be $debug only, try:

$r = mail($to, $subject, $message, $headers);
var_dump($r); 

6 Jan 11, 2008 23:53

Ok, I got this with $debug = 2

Sending mail from «b2evo@myhost» to «valid email», Subject «=?ISO-8859-1?B?0J/QvtC00YLQstC10YDQtNC40YLRjCDQstCw0YggZW1haWwg0LDQtNGA?= =?ISO-8859-1?B?0LXRgSDQtNC70Y8gIm5ldzEi?=» FAILED.

didn't check it for contact form yet

7 Jan 11, 2008 23:58

Back to basics
There must be an active mail() function because if I add:

mail($to, $subject, $message, $headerstring)


I get two emails. So

  1. The function should work as advertised

  2. mail($to, $subject, $message, $headerstring) also should function

  3. I still cannot find mail()

  4. Your problem is related to the GoDaddy setup.

  5. [/list:o] If you do $debug=1 in /conf/_advanced.php, does it give extra and interesting debug info?

8 Jan 12, 2008 00:23

I'm now trying to resolve it. Will post my solution here. Thanks

9 Jan 12, 2008 00:35

I added my own subject

$subje = "Some subject";

mail($to, $subje, $message, $headerstring)

and message was sent!

Moving forward...

10 Jan 12, 2008 00:44

I forgot to tell that the subject of the mail sent from contact form is always like РлекСандС.

It seems to be the same problem with registration, but in this case it sends something very bad in Subject :)

11 Jan 12, 2008 00:46

Can it be it goes wrong in this piece?

	// Convert encoding of message (from internal encoding to the one of the message):
$message = convert_charset( $message, $current_charset, $evo_charset );


/inc/_core/_misc.funcs.php lines 1763-1764

	if( function_exists('mb_encode_mimeheader') )
	{ // encode subject
		$subject = mb_encode_mimeheader( $subject, mb_internal_encoding(), 'B', $NL );
	}


lines 1756-1759

12 Jan 12, 2008 00:52

Ok, I renamed ru-RU folder in locales and everything works fine with regular subject string. It is an encoding problem

13 Jan 12, 2008 00:56

sam2kb wrote:

Ok, I renamed ru-RU folder in locales and everything works fine with regular subject string. It is an encoding problem

Cool

Getting somewhere

14 Jan 12, 2008 00:59

/xmlsrv/message_send.php lines 221-222

	// We don't know the recipient's language - Change the locale so the email is in the blog's language:
locale_temp_switch($Blog->locale);


But i presume you noticed this already. Now simply try to get the $subject out of there

15 Jan 12, 2008 06:12

All right, here is the solution (at least for me on UTF-8 with Russian text).

In /inc/_core/_misc.funcs.php on line 1756 I changed

$subject = mb_encode_mimeheader( $subject, mb_internal_encoding(), 'B', $NL );

to

$subject = "=?utf-8?B?". base64_encode($subject). "?=";

Validation messages sent perfect! And this part is done.

I'm not a dev, so I let you guys to work around :)

But when I send messages with contact/comment form, the recipient_name and sender_name are always in wrong encoding (actually they're not encoded at all)

To: ааЛаЕаКбаАаНаДб
Subject: =?utf-8?B?0JDQu9C10LrRgdCw0L3QtNGA?=
From: ааЛаЕаКбаАаНаДб

Now I'm working on it.

EDIT: this also works with

$subject = "=?$evo_charset?B?". base64_encode($subject). "?=";

16 Jan 12, 2008 07:13

To encode TO: and FROM: fields

open /htsrv/message_send.php find and change

on line 113


$sender_name = param( 'd', 'string', '' );
$sender_name = "=?$evo_charset?B?". base64_encode($sender_name). "?=";

on line 191


$recipient_name = trim($recipient_User->get('preferredname'));
$recipient_name = "=?$evo_charset?B?". base64_encode($recipient_name). "?=";

on line 220


$recipient_name = trim($Comment->get_author_name());
$recipient_name = "=?$evo_charset?B?".base64_encode($recipient_name). "?=";

Now my blog IS multilingual :)

17 Jan 12, 2008 09:43

After several tests I found that the comments aren't have encoded FROM string, while registration and contact forms work perfect.

I give up... :(

18 Jan 26, 2008 07:57

Can we move this topic in bugs section. This problem is not fixed in 2.4.0 version. All headers sent unencoded.

All emails coming from my blog have unreadable headers, and I can't set email validation for users because mail() function fails.

Does anybody here use non-latin Language packs?

19 Apr 10, 2008 05:29

bump

Why the mail function doesn't encode the headers? We can add a simple 3-lines patch and the problem is gone.

20 Apr 11, 2008 00:14

OK I'll check that out for the next release.

22 Apr 12, 2008 22:15

OK, I have added a "clean" version of this to CVS.
By clean I mean it's not going to break the tests for empty strings or pass something weird to the plugins.
Have a look.

23 Apr 12, 2008 23:29

I tried that, it doesn't fix validation emails. I thought of doing it globally by adding something like this in mail function in _misc.funcs.php.
I'm not a regex expert so there might be a better solution, but I use this code and it works perfect.

$from_name = preg_replace( '/^(.+?)<(.*?)>$/', '$1', $from );
$from_email = preg_replace( '/^.*?<(.+?)>$/', '$1', $from );

//$from_name = '' in validation messages
if ( $from_name != $from_email )
{
	$from = "=?$evo_charset?B?".base64_encode( $from_name )."?=".' <'.$from_email.'>';
}
	
$headers['From'] = $from;

$subject = "=?$evo_charset?B?".base64_encode($subject)."?=";

24 Apr 13, 2008 17:20

Ok, I have moved all the base64_encodes into send_mail() and I've added it to $to, $from and $subject.

Can you check again?

Also, can you please confirm what you get when you go to Admin > Tools > System under "PHP mbstring extension" ?

Thanks.


Form is loading...