Solved

Warning: mail() [function.mail]: SMTP server response: 503 Bad command sequence in C:\Inetpub\wwwroot\republicncc.com\mail1.php on line 24

Posted on 2004-08-12
4
2,217 Views
Last Modified: 2008-01-09
Ok..i'm in the process of moving a website from a linux host to a windows 2k host.  I've installed php for windows and the pages come up fine.  i'm having a problem though getting the form to work.  Its generating this error
Warning: mail() [function.mail]: SMTP server response: 503 Bad command sequence in C:\Inetpub\wwwroot\republicncc.com\mail1.php on line 24

Here is the code from that page:

<?php
       include("layout/meta.htm");
      include("layout/body.htm");      
      include("layout/logo.htm");
      include("layout/topnav.htm");            
      include("layout/leftnav.htm");
      include("layout/maintop-mail.htm");
      
$msg  = "Senders Name:\t$name\n";      
$msg .= "Senders E-Mail:\t$email\n";
$msg .= "Senders Telephone:\t$phone\n";
$msg .= "Recipient of this message:\t$recipient\n";
$msg .= "Subject:\t$subject\n";
$msg .= "Comment:\t$comments\n";

// use two newline characters at the end of your content,
// or to insert additional spacing

$mailheaders = "To: $recipient";
$mailheaders .= "$name<> \n";
$mailheaders .= "Reply-To: $email\n\n";

mail("$recipient", "$subject", $msg, $mailheaders);

 
echo "<P>&nbsp;";
echo "<CENTER><TABLE><TR><TD WIDTH=400";
echo "<H3>Hello, $name.";
 
echo "Thank you for your visiting the <B>R.N.C.C.</B> official web site.\n";
echo "Your message below has been transmitted to us.\n";
 
echo " $name,we appreciate your visit!</H3> ";
echo "<A HREF=\"http://www.republicncc.com\">Return to Main page</A></CENTER>";
echo " </BLOCKQUOTE></TD></TR></TABLE> </TD></TR>";
 
      
      include("layout/mainbottom.htm");            
      include("layout/footer.htm");

?>

The email is hosted on a remote server.  The remote server is the same one that was accessed from the other old linux site (the linux site accessed a remote server as well..the same one trying to access now).  I've configured the smtp settings properly. Any ideas on what the problem could be?

THanks
0
Comment
Question by:diglife
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
eric_j_kropf earned 500 total points
ID: 11786527
Did you try:

mail($recipient, $subject, $msg, $mailheaders);

instead of :

mail("$recipient", "$subject", $msg, $mailheaders);



(http://www.devarticles.com/c/a/PHP/Getting-Intimate-With-PHPs-Mail-Function/1/)
0
 
LVL 1

Expert Comment

by:eric_j_kropf
ID: 11786585
Also, reading on... you are now on a windows server? mail() uses the SMTP sever specified in the php.ini file. If you are sending mail through a remote SMTP server, I think you will need to do it using a different method than using the mail() function.

I had a problem before an used a smtp class from http://www.phpguru.org/downloads/smtp/. Just use winrar or winzip to extract it and follow the examples.

Hope this helps some.
0
 
LVL 4

Expert Comment

by:Devastated
ID: 11786807
Hi,

it looks like the inherent problem you maybe experiencing stems from mail itself...

The Win32 implementation of mail() is notoriously flaky. one approach is to write the raw email directly out to the pickup folder in mailroot. A
function along these lines should help you out:

function sendMail($mailto, $mailfrom, $subject, $text, $format)
      {
      $maildrop="c:\\inetpub\\mailroot\\pickup\\";//change this to the
location of your mailroot

      $filename=<work out some random filename here>;
      $fp=fopen($maildrop.$filename, "w");

      //different headers for different mail types
      if($format=="plain")
            fwrite($fp,"Content-Type: text/plain\r\nFrom:
$mailfrom\r\n");
      else if($format=="html")
            fwrite($fp,"Content-Type: text/html;
charset=iso-8859-1\r\nFrom: $mailfrom\r\n");

      //write the email out to the file
      fwrite($fp,"To: <$mailto>\r\n");
      fwrite($fp,"Subject: $subject\r\n");
      fwrite($fp,"\r\n");
      fwrite($fp,"$text\r\n\r\n");
      fclose($fp);
      }
0
 
LVL 18

Expert Comment

by:arantius
ID: 11789433
What are the likely contents of $name and $recipient?  That doesn't quite look valid.  And yes, you definetly do not need the "" quotes around the variables in the call to mail()
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

932 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

9 Experts available now in Live!

Get 1:1 Help Now