Jump to content

Recommended Posts

Hello, I am new to php and currently using the book creating interactive websites with php and webservices. The email class created is shown below:

 

<?php

class Email {

 

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

 

}

}

?>

 

 

The code below is from my php script:

 

$userid = mysql_insert_id();

$verify_url = "http://".$_SERVER['SERVER_NAME'].

  "/join.php?req=verify&id=$userid&vcode=".

  md5($_POST['first_name']);

 

$mailer = &new Email;

//Email user

//$_POST['email_address']

$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 would find information".

"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();

 

After successfully inserting data in the database, i however receive no email... could some please help me out

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/174045-sending-email-with-php/
Share on other sites

Hi,

I'm not hot on php classes but have you missed out these lines from the Email class?:

var $From;
   var $FromName;
   var $ToMail;
   var $ToName;
   var $Subject;
   var $Message;

 

ie:

class Email {
   var $From;
   var $FromName;
   var $ToMail;
   var $ToName;
   var $Subject;
   var $Message;

  etc.

 

Also, I am not convinced that you want the ampersand (&) in this line:

$mailer = &new Email;

That should probably be this:

$mailer = new Email;

 

Chris

Hi,

I'm not hot on php classes but have you missed out these lines from the Email class?:

var $From;
   var $FromName;
   var $ToMail;
   var $ToName;
   var $Subject;
   var $Message;

 

ie:

class Email {
   var $From;
   var $FromName;
   var $ToMail;
   var $ToName;
   var $Subject;
   var $Message;

  etc.

 

Also, I am not convinced that you want the ampersand (&) in this line:

$mailer = &new Email;

That should probably be this:

$mailer = new Email;

 

Chris

 

He may be referrencing, albeit incorrectly..

$mailer =& new Email;

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.