Why won't PHP Mail send emails to hyphenated email addresses (e.g.

Posted June 1, 2015 5.8k views

It works fine with email addresses without hyphens (e.g. Does anyone know a possible cause for this?

Please ask if you need any more information.

  • Can you share a sample of the code attempting to send the messages?

    I have never encountered this myself when sending emails via php but some googling found a number of people reporting similar issues and the primary suggestions I found there were:

    • Escape the hyphen: digital\
    • Wrap the email in quotes: ""
    • use angle brackets: <>
  • Here is the script. As you can see I’m using PHP Mailer

    require 'PHPMailer.php';
    $name = $_POST['name'];
    $email = $_POST['email'];
    $tel = $_POST['tel'];
    $where = $_POST['where'];
    $message = $_POST['message'];
    $to = "";
    if ($where == "one") {
      $to = "";
    } elseif ($where == "two") {
      $to = "";
    $mail = new PHPMailer;
    $mail->From = '';
    $mail->FromName = 'Website Contact Form';
    $mail->Subject = "Contact Form Submission";
    $mail->Body = "<b>Name:</b> " . $name . "<br><br><b>Email:</b> " . $email . "<br><br><b>Telephone:</b> " . $tel . "<br><br><b>Where They Are:</b> " . $where . "<br><br><b>Message:</b> " . $message; 


  • Looking at PHPMailer’s source code, it appears to encode a recipient email address only if there is a name. Try passing a name to addAddress(), does that work?

    $mail->addAddress($to, 'Name here');
  • I tried that and it didn’t work. I think it says somewhere that the name isn’t required anyway.

  • Now I can’t send emails at all. I get this line in my mail.log

    Jun  2 16:33:54 McCarthee sm-mta[22590]: t52KXqS3022588: t52KXsS3022590: DSN: Service unavailable

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @McCartheee,

This looks like some kind of an encoding issue nothing else. I’m not sure it’s actually part of the phpMailer class or just the way your strings are being saved.

Additionally, try to use the most up to date PHP version and see if the error would be again experienced.