I keep getting a malformed address: error

Posted on 2004-11-29
Last Modified: 2013-12-12
I keep getting a malformed address: error

A message that you sent contained one or more recipient addresses that were
incorrectly constructed: <>: malformed address: <> may not follow

This address has been ignored. The other addresses in the message were
syntactically valid and have been passed on for an attempt at delivery.

Here's the code I'm using:


// send email
$myname = $contact_name;
$myemail = $contact_email;

$contactname = $signup[fname];
$contactemail = $signup[email];
$message = "Hello ".$signup[fname].",<BR>".
"Get ready to start getting the hits you deserve.  Now here is your login info:<BR><BR>".
"username: ".$signup[username]."<BR>".
"password: ".$signup[password]."<BR><BR>".
"<B>The next step is to click on this link to activate your account: <a href=".$siteUrl."activate.php?username=".$signup[username].">CLICK HERE</a></b>";
$subject = $title;

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactemail." <".$contactname.">\r\n";
$headers .= "Reply-To: ".$myname." <".$myemail.">\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";

mail($contactemail, $subject, $message, $headers);
$signup[username] = "";


I have just changed to a new server.  
This code worked fine on the my last server with no errors.

Question by:phpnovice
    LVL 2

    Expert Comment

    What is the mail server that you are using ?

    LVL 2

    Expert Comment

    You might try the phpMailer class for sending emails..
    I'm using it to send multiple emails on PHP 4.3.9 +Exchange Server 5.0

    LVL 9

    Accepted Solution

    What about this line..
    $headers .= "To: ".$contactemail." <".$contactname.">\r\n";
    ..should be
    $headers .= "To: "..$contactname" <".$contactemail.">\r\n";

    You have put contact name in place where contact mail should be.

    LVL 9

    Expert Comment

    Ups, just correct dot postiton.

    $headers .= "To: " . $contactname . " <" . $contactemail . ">\r\n";

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now