Title: PHPMailer
Last modified: September 1, 2016

---

# PHPMailer

 *  Resolved [kordas88](https://wordpress.org/support/users/kordas88/)
 * (@kordas88)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/)
 * Hi everyone!
 * I have a problem, which I can’t solve for quite a while. I created a site in 
   polish using UTF-8. Everything on the site works perfectly – there are polish
   characters. But when I use contact form (it was a part of the theme – it uses
   PHPMailer), I receive a message with weird letters like Ă. I changed charset 
   to UTF-8 in class-phpmailer.php, but this error still occurs. Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [cedcommerce](https://wordpress.org/support/users/cedcommerce/)
 * (@cedcommerce)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/#post-7484743)
 * Hi kordas88,
    Check your phpMailer code and find the line where object of phpMailer
   is being created.Now try this piece of code :
 *     ```
       $mail = new PHPMailer();
       $mail->CharSet = "UTF-8";
       $mail->Encoding = "16bit";
       ```
   
 * Hope this will fix your problem.
    Thanks
 *  Thread Starter [kordas88](https://wordpress.org/support/users/kordas88/)
 * (@kordas88)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/#post-7484797)
 * It may sound stupid, but there actually is no “new PHPMailer” line in any file
   of my website (i checked that with a script). I’m sure it’s created somehow, 
   but I have no idea, where to find it. I know, that my message is created here:
 *     ```
       // AJAX Callback: Send contact form data
       if ( !function_exists( 'sc_contact_form_send' ) ) {
       	function ancora_sc_contact_form_send() {
       		global $_REQUEST;
   
       		if ( !wp_verify_nonce( $_REQUEST['nonce'], 'ajax_nonce' ) )
       			die();
   
       		$response = array('error'=>'');
       		if (!($contact_email = ancora_get_theme_option('contact_email')) && !($contact_email = ancora_get_theme_option('admin_email')))
       			$response['error'] = __('Nieznany e-mail administratora!', 'ancora');
       		else {
       			$type = ancora_substr($_REQUEST['type'], 0, 7);
       			parse_str($_POST['data'], $post_data);
   
       			if ($type=='contact') {
       				$user_name	= ancora_strshort($post_data['username'],	100);
                       $last_name	= ancora_strshort($post_data['lastname'],	100);
       				$user_email	= ancora_strshort($post_data['email'],	100);
                       $user_phone	= ancora_strshort($post_data['phone'],	100);
       				$user_msg	= ancora_strshort($post_data['message'],	ancora_get_theme_option('message_maxlength_contacts'));
                       $user_serv	= ancora_strshort($post_data['service'],	100);
   
                       $subj = sprintf(__('Strona %s - wiadomosc od %s', 'ancora'), get_bloginfo('site_name'), $user_name);
       				$msg = "\n".__('Imie:', 'ancora')   .' '.esc_html($user_name)
                           .  "\n".__('Nazwisko:', 'ancora')   .' '.esc_html($last_name)
       				//	.  "\n".__('E-mail:', 'ancora') .' '.esc_html($user_email)
                           .  "\n".__('Telefon:', 'ancora') .' '.esc_html($user_phone)
       					.  "\n".__('Wiadomosc:', 'ancora').' '.esc_html($user_msg);
                          // .  "\n".__('Usługa:', 'ancora').' '.esc_html($user_serv);
       ```
   
 * My host supplier says it should work fine.
 *  [cedcommerce](https://wordpress.org/support/users/cedcommerce/)
 * (@cedcommerce)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/#post-7484865)
 * The issue seems to be in line:
    `$user_msg = ancora_strshort($post_data['message'],
   ancora_get_theme_option('message_maxlength_contacts'));`
 * Try replacing the line by :
    `$user_msg = sanitize_text_field($post_data['message’]);`
   Or : `$user_msg = utf8_decode(sanitize_text_field($post_data['message’]));` If
   issue still persist please send the code of function ancora_strshort()
 * Thanks
 *  Thread Starter [kordas88](https://wordpress.org/support/users/kordas88/)
 * (@kordas88)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/#post-7484872)
 * It actually works! Thank you so much for your help!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHPMailer’ is closed to new replies.

## Tags

 * [charset](https://wordpress.org/support/topic-tag/charset/)
 * [phpmailer](https://wordpress.org/support/topic-tag/phpmailer/)
 * [utf-8](https://wordpress.org/support/topic-tag/utf-8/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [kordas88](https://wordpress.org/support/users/kordas88/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/phpmailer-2/#post-7484872)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
