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 = [email protected]

 

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 = "[email protected]";
   $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
https://forums.phpfreaks.com/topic/92766-mail-function-error-how-to-set-smtp-up/
Share on other sites

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.

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.