treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Email Signup Issue

  • I made a basic email signup form and I'm not sure what happen here, but it was working fine for a long time, but all of a sudden I'm getting the follow errors.

    • Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\inetpub\vhosts\citysightseeingtoronto.com\httpdocs\newsletter.php on line 19
    • Warning: Cannot modify header information - headers already sent by (output started at C:\inetpub\vhosts\citysightseeingtoronto.com\httpdocs\newsletter.php:19) in C:\inetpub\vhosts\citysightseeingtoronto.com\httpdocs\newsletter.php on line 21
    <?php
    $errors = '';
    $myemail = 'newsletter@citysightseeingtoronto.com';//<-----Put Your email address here.
    $email_address = $_POST['email'];
    if (!preg_match(
    "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
    $email_address))
    {
        $errors .= "\n Error: Invalid email address";
    }
    if( empty($errors))
    {
      $to = $myemail;
      $email_subject = "Newsletter Signup submission";
      $email_body = "You have received a new message. ".
      " Here are the details:\n Email: $email_address";
      $headers = "From: $myemail\n";
      $headers .= "Reply-To: $email_address";
      mail($to,$email_subject,$email_body,$headers);
      //redirect to the 'thank you' page
      header('Location: newsletterthanks.php');
      }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank" rel="nofollow">http://www.w3.org/TR/html4/loose.dtd">
    
    
    
    Contact form handler
    
    
    
    <?php
    echo nl2br($errors);
    ?>
    
    

    Can anyone tell me what I've done wrong TIA!