daydreamer Posted February 24, 2008 Share Posted February 24, 2008 Hi. Im trying to get a registration form to work. It is meant to email the user of their login details. I am using Windows Vista, and the WAMP (PHP, Apache and MySql) set up. Trying to use my ISP's mail server, but i dont think this is the problem, here is my php.ini: [mail function] ; For Win32 only. SMTP = smtp.ntlworld.com smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com The mail function I am using, is a separate class which gets included into the Join.php form: clsEmail.php <?php class Email { var $From; var $FromName; var $ToMail; var $ToName; var $Subject; var $Message; function SendMail(){ $Message = stripslashes($this->Message); $Message = stripslashes($this->Message); $headers .="From: ".$this->FromName. "<".$this->FromMail.">\n"; $headers .="Reply-To: ".$this->FromName. "<".$this->FromMail.">\n"; //$headers .="X-Priority: 1\n"; //$headers .="X-MSMail-Priority: High\n"; $headers .="X-Mailer: My PHP Mailer\n"; $headers .="Origin: ".$_SERVER['REMOTE_ADDR']."\n"; mail($this->ToMail, $this->Subject, $Message, $headers); // This is LINE 21 <<<<< where the error is reported. <<<<<<<<<<< } } ?> and this is the code which executes after the user has entered details, and clicked submit: Join.php // (validation code and entering details into database above this) <?php $mailer = &new Email; // initialise email class. (clsEmail.php in classes folder) // Email user $mailer->ToMail = $_POST['email_address']; $mailer->FromMail = "admin@test.com"; $mailer->FromName = "My PHP Site Administrator"; $mailer->Subject = "Your Membership at My PHP Site"; $mailer->Message = "Dear $_POST[first_name],\n". "Thanks for joining our website! We". " welcome you and look forward to". " your participation.\n\n". "Below you will find the ". "information required to ". "Login to our website!\n\n". "First, you will need to verify". " your email address ". "by clicking on this ". "hyperlink:\n$verify_url\nand ". "following the directions in your ". " web browser.\n\n". "=====================\n". "Username: $_POST[username]\n". "Password: $_POST[password]\n". "UserID: $userid\n". "Email Address: ". "$_POST[email_address]\n". "=====================\n\n". "Thank you,\n". "My PHP Site Administrator\n". "http://$_SERVER[sERVER_NAME]\n"; $mailer->SendMail(); ?> and this is the error I get: Warning: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments in C:\wamp\www\classes\clsEmail.php on line 21 Warning: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments in C:\wamp\www\classes\clsEmail.php on line 21 Help appreciated Quote Link to comment Share on other sites More sharing options...
schilly Posted February 24, 2008 Share Posted February 24, 2008 hmmm I've never had to set my smtp server in the php.ini file for using the mail function. Doesn't it just run through sendmail? Edit: ah nm. http://ca3.php.net/manual/en/ref.mail.php. Those are Windows only options so I've never used them. Quote Link to comment Share on other sites More sharing options...
daydreamer Posted February 24, 2008 Author Share Posted February 24, 2008 lol Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted February 24, 2008 Share Posted February 24, 2008 why can't you use the mail() function? Quote Link to comment Share on other sites More sharing options...
daydreamer Posted February 24, 2008 Author Share Posted February 24, 2008 I am using the mail function, as you see in the clsEmail.php. mail($this->ToMail, $this->Subject, $Message, $headers); // This is LINE 21 <<<<< where the error is reported. <<<<<<<<<<< The reason I have it in a class file, is because I can use it as a function to send emails and save code if i need to use it across loads of different pages. I am following a tutorial book and this is how hes done it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.