...

View Full Version : some string doesn't work



Rockey123
02-08-2010, 02:41 PM
<?php
class Mailer
{
/**
* sendWelcome - Sends a welcome message to the newly
* registered user, also supplying the username and
* password.
*/
function sendWelcome($user, $email, $pass){
include_once 'settings.php';
$from = "From: ".$domain." Info <".EMAIL_FROM_ADDR.">";
$subject = " Welcome ".$user."! ".$domain." registration info";
$body = $user.",\n\n"
."Welcome! You've just registered at ".$domain." "
."with the following information:\n\n"
."Username: ".$user."\n"
."Password: ".$pass."\n\n"
."If you ever lose or forget your password, a new "
."password will be generated for you and sent to this "
."email address, if you would like to change your "
."email address you can do so by going to the "
."My Account page after signing in.\n\n"
."$domain Staff";

return @mail($email,$subject,$body,$from);
}

/**
* sendNewPass - Sends the newly generated password
* to the user's email address that was specified at
* sign-up.
*/
function sendNewPass($user, $email, $pass){
include_once 'settings.php';
$from = "From:".$domain." Password <".EMAIL_FROM_ADDR.">";
$subject = "$user, your new password has been generated at ".$domain." ";
$body = $user.",\n\n"
."We've have generated a new password for you at your "
."request, you can use this new password with your "
."username to log in to our website\n\n"
."Username: ".$user."\n"
."New Password: ".$pass."\n\n"
."It is recommended that you change your password "
."to something that is easier to remember, which "
."can be done by going to the My Account page "
."after signing in.\n\n"
."$domain Staff";

return mail($email,$subject,$body,$from);
}

function sendPlaylist($user, $email, $msg){
include_once 'settings.php';
$from = "From: ".$domain." <".EMAIL_FROM_ADDR.">";
$subject = "$user just share you a playlist from - ".$domain."";
$body ="Hi,\n\n"
."$user has shared this playlist.\n"
."$msg\n\n"
."$domain Staff";

return mail($email,$subject,$body,$from);
}

};

/* Initialize mailer object */
$mailer = new Mailer;

?>

this email what I get.. some string doesn't work..


pardork,

Welcome! You've just registered at with the following information:

Username: pardork
Password: pardork

If you ever lose or forget your password, a new password will be generated for you and sent to this email address, if you would like to change your email address you can do so by going to the My Account page after signing in.

Staff

*note = pardork is example of username & password..

can someone help me fix on this?

Fou-Lu
02-08-2010, 02:47 PM
$domain by chance? You need to be more specific when something is not working properly.
$domain is not within scope, pass it into you're function parameters or ensure its in you're settings file.

SKDevelopment
02-08-2010, 02:55 PM
I think $domain is defined in settings.php, right ?

I would not include the settings.php to the function scope using include_once(). Maybe include() would work, but I would not do that either.

Move your include_once to the very top of the script (to the global scope from the function scope). And then
- either add


global $domain;

to your functions (not recommended)

- or add $domain as a parameter to the functions (exactly as Fou-Lu said)

- or (I would follow this way) define your domain as a constant


define('MY_DOMAIN','domain.com');

in the configuration file and use it anywhere you need (constant would be available in any scope after it is defined and you would need your domain in more than one place in your system most probably).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum