Jump to content

mail function error. How to set SMTP up?


daydreamer

Recommended Posts

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 :)

 

 

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.