title: PHP how to use idn_to_ascii for mail adresses
body: <p>since it's possible to have Umlaute (e.g. öäü) in the local part of an email address I need to convert them to ascii because Zend-Mail is not able to handle it - it always throws invalid header exception.</p>
  
  <p>So there is this php-function <a href="http://php.net/manual/de/function.idn-to-ascii.php" rel="nofollow noreferrer">idn_to_ascii</a> which converts domain names to IDNA ASCII format. The problem is that I'm not sure how to use it correctly.</p>
  
  <p>Let's take this email address: testö@domain.com</p>
  
  <pre><code>// doesn't work (unknown error):
  idn_to_ascii('testö@domain.com') --&gt; xn--test@domain-ufb.com
  </code></pre>
  
  <p>If I just convert the local part of the email address it seems to work:</p>
  
  <pre><code>idn_to_ascii('testö') --&gt; xn--test-8qa@domain.com
  </code></pre>
  
  <p>But what if also the domain part contains Umlaute?<br>
  e.g. testö@domainö.com</p>
  
  <p>should I do something like this?</p>
  
  <pre><code>idn_to_ascii('testö').'@'.idn_to_ascii('domainö.com')
  </code></pre>
  
  <p>Also on the php-homepage someone wrote a comment that you have to skip the high-level domain part (and the official documentation is wrong):
  <a href="http://php.net/manual/de/function.idn-to-ascii.php#108900" rel="nofollow noreferrer">see here</a></p>
  
  <pre><code>idn_to_ascii('domainö') // right
  idn_to_ascii('domainö.com') // wrong
  </code></pre>
  
  <p>I'm so confused now :|<br>
  Someone has experience in that? And the worst thing is: I can't even test it because I don't have an email address with Umlaute.</p>