We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21496
    • 225 Posts
    There’s a thread in the General Support forum about problems sending mails from the manager. If high ASCII characters are used, the output is garbled.

    I found a solution by modifying save_user.processor.php, making use of the phpmailer class. The funciton sendMailMessage (Line 455) needs to be replaced by this modified version:

    // Send an email to the user
    function sendMailMessage($email, $uid, $pwd, $ufn) {
    	global $signupemail_message;
    	global $emailsubject, $emailsender;
    	global $site_name, $site_start, $site_url;
    	global $modx;
    	$manager_url = $site_url . "manager/";
    	$message = sprintf($signupemail_message, $uid, $pwd); // use old method
    	// replace placeholders
    	$message = str_replace("[+uid+]", $uid, $message);
    	$message = str_replace("[+pwd+]", $pwd, $message);
    	$message = str_replace("[+ufn+]", $ufn, $message);
    	$message = str_replace("[+sname+]", $site_name, $message);
    	$message = str_replace("[+saddr+]", $emailsender, $message);
    	$message = str_replace("[+semail+]", $emailsender, $message);
    	$message = str_replace("[+surl+]", $manager_url, $message);
    	
    	# include PHP Mailer
    	include_once "../manager/includes/controls/class.phpmailer.php";
    
    	# send form
    	$mail = new PHPMailer();
    	$mail->IsMail();
    	$mail->CharSet = $modx->config['modx_charset'];
    	$mail->AddAddress($email);
    	$mail->From		= $emailsender;
    	$mail->FromName	= $site_name;
    	$mail->Subject	= $emailsubject;
    	$mail->Body		= $message;
    	if(!$mail->send()) {
    		webAlert('An Error occurred: ' . $mail->ErrorInfo);
    		exit;
    	}
    }
    
    


    Adding that header information also makes it less likely those mails get caught in spam filters. The function is checking now for the charset as defined in the manager, adjusting it in case it’s not utf8.
      René
      • 21496
      • 225 Posts
      Quote from: BobRay at Nov 10, 2007, 04:34 PM

      Wouldn’t leaving the To: address blank cause an error?

      Ah, so simple - yes it does cause an error. I was adjusting the error handling to make use of webalert (otherwise it was not displayed properly), and I was removing the second post in this thread.
        René
        • 18878
        • 210 Posts
        Hi,

        I replaced your new code and then under Tools=>Configuration=>User I changed some text at the section Web Reminder Email. I included some international characters like: ignórelo. Then I tested it and clicked on the Lost Password option on the webiste. The email with new password activation arrived, but the international characters are still garbled: ignórelo.

        Did I forget to tweak something else? (My character encoding is Unicode (UTF-8) - utf-8 )

        Thanks.

        Mc