Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    some string doesn't work

    PHP Code:
    <?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?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    $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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    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
    PHP Code:
    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
    PHP Code:
    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).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •