Results 1 to 9 of 9

Thread: PHP Email Activation Link

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Email Activation Link

    I have a code to send activation link to user email and click it for account activation. I am using PHPMailer for sending mail and configure SMTP authentication but email not sent yet and shown:

    Mailer Error: Language string failed to load: data_not_accepted

    I have put phpmailer.lang-en.php under htdocs folder already,so what mighht cause this error?Thanks....

    The following is my form processing code:

    PHP Code:
    <?php
    ini_set
    ("include_path""path/to/language/file");
    //Connect to mysql database
    $conn mysql_connect("localhost""root""") or die('Could not connect: ');
    $db mysql_select_db("movie_ticket_booking"$conn) or die('Could not select database');

    //global variable
    $table1 "temp_members";
    $table2 "registered_member";

    //Random confirmation code
    $confirm_code md5(uniqid(rand()));

    //This code runs if the form has been submitted
    if (isset($_POST['submit']))
    {
      
        
    // checks if the email address is alredy registered
        //if (!get_magic_quotes_gpc())
        //{
        //$_POST['email'] = addslashes($_POST['email']);
        //}
        
    $emailcheck $_POST['email'];
        
    $check mysql_query("SELECT email FROM $table2 WHERE email = '$emailcheck'") or
            die(
    mysql_error());
        
    $check2 mysql_num_rows($check);

        
    //if the name exists it gives an error
        
    if ($check2 != 0)
        {
            die(
    'Sorry, the email address' $_POST['email'] . ' is already registered.');
        }

         
    // encrypt the password
        
    $pass1 md5($pass1);
        
    //if (!get_magic_quotes_gpc())
        //{
        //pass1 = addslashes($pass1);
        //$_POST['member_id'] = addslashes($_POST['member_id']);

        //Insert record to database
        
    $insert mysql_query("INSERT INTO $table1(confirm_code,name,email,password,tel,address)
                              VALUES ('
    $confirm_code','" $_POST['name'] . "','" $_POST['email'] .
                              
    "', '" $_POST['pass1'] . "','" $_POST['tel'] . "','" $_POST['address'] ."')")
                               or die(
    mysql_error());


        
    // }

        //if successfully inserted,send confirmation link to email
        
    if ($insert)
        {
            
            echo 
    "thank for your registration!";

            require (
    "class.phpmailer.php");

            
    $mail = new PHPMailer();
            
    $mail->IsSMTP();
            
    $mail->Host "localhost";
            
    $mail->SMTPAuth true;// turn on SMTP authentication
            
    $mail->Username "root";// SMTP username
            
    $mail->Password "";// SMTP password
            
    $mail->SetLanguage("en","phpmailer/language");

            
    //compose mail
            
    $mail->From "admin@localhost.com";
            
    $mail->FromName "Cinema Admin";
            
    $mail->AddAddress($_POST['email']);
            
    $mail->AddReplyTo("admin@localhost.com""Cinema Admin");
            
    $mail->Subject 'Your confirmation link here';
            
    $mail->Body "Your confirmation link\r\n";
            
    $mail->Body .= "Click on this link to activate your sccount\r\n";
            
    $mail->Body .= "http://localhost/www/confirm.php?passkey=$confirm_code";


            
    //send mail
            
    if (!$mail->Send())
            {
                echo 
    "Message was not sent <p>";
                echo 
    "Mailer Error: " $mail->ErrorInfo;
                exit;
            }

            echo 
    "Message has been sent";
        }

        
    //if not found
        
    else
        {
            echo 
    "Not found your email in our database";
        }

        
    //if your email successfully sent
        //if ($sentmail)
        //{
        //echo "Your confirmation link has been sent to your email address.";
        //}

        //else
        //{
        // echo "Cannot send confirmation link to your email address.";
        //}

    }
    ?>
    sendmail portion in php.ini
    PHP Code:
    [mail function] 
    ; For 
    Win32 only
    SMTP localhost 
    smtp_port 
    25 

    ; For Win32 only
    sendmail_from admin@localhost.com 

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Do you actually have a mail server installed on your server? If not, that would be the reason for your script failure. If you already do have a mail server, make sure that the user info for the account you are going to use to send the email with is correct in this portion of the code:

    Code:
     $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->Host = "localhost";
            $mail->SMTPAuth = true;// turn on SMTP authentication
            $mail->Username = "{USERNAME HERE}";// SMTP username
            $mail->Password = "{PASSWORD HERE}";// SMTP password
            $mail->SetLanguage("en","phpmailer/language");
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am running Local SMTP Server Pro in my localhost server.My computer is listening to telnet localhost 25.

    I had created an account admin@localhost.com under Outlook Express with following username and password which I specified in sendmail form and class.phpmailer.php sendmail portion.
    PHP Code:
           mail = new PHPMailer();
            
    $mail->IsSMTP();
            
    $mail->Host "localhost";
            
    $mail->SMTPAuth true;// turn on SMTP authentication
            
    $mail->Username "admin";// SMTP username
            
    $mail->Password "itc309";// SMTP password
            
    $mail->SetLanguage("en","phpmailer/language"); 
    PHP Code:
     /**
         *  Sets SMTP authentication. Utilizes the Username and Password variables.
         *  @var bool
         */
        
    var $SMTPAuth     true;

        
    /**
         *  Sets SMTP username.
         *  @var string
         */
        
    var $Username     "admin";

        
    /**
         *  Sets SMTP password.
         *  @var string
         */
        
    var $Password     "itc309"
    However,I can neither run my script nor send out mail through localhost account in Outlook Express...What went wrong actually??

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Did you make the same user account in the actual SMTP Server software? If not, then there is your problem. Not sure exactly how you would do it, being that I never messed with the program before; but there should be something that talks about "Users" or "Accounts". In there, you should be able to add your user account and making the script work for you.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That SMTP server software only allow me to cinfigure account under Outlook Express and I implement the same account setting under Outlook,send mail form and class.phpmailer.php

    From Adress:admin@localhost
    User Name:admin
    Password:itc309
    Incoming Server(POP3):localhost
    Outgoing Server(SMTP):localhost

    So,what might went wrong?thanks...

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Let me download the software and I'll be able to troubleshoot this a bit more. Just a thought off the top of my head though, did you open the port 25 in your firewall/router? Other than that, I need to run some tests to try and recreate what you are experiencing.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your initiative.I can do telnet localhost 25 seems port is opened.

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    For some reason, the server software doesn't want to download and install on my computer properly; so I can't fully replicate your problem. Something that I am wondering; after looking at the documentation for phpmailer, is there a reason for this line?

    Code:
    $mail->SetLanguage("en","phpmailer/language");
    All the examples I have seen in the documentation does not include this line. Perhaps try taking that out and see if that works.

    //EDIT: This still doesn't explain the reason for your outlook express not sending out. The only thing I could recommend is either moving your script to a different server, or downloading a different mail server software (such as hMailServer).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by devil_vin View Post
    I had created an account admin@localhost.com under Outlook Express with following username and password which I specified in sendmail form and class.phpmailer.php sendmail portion.

    However,I can neither run my script nor send out mail through localhost account in Outlook Express...What went wrong actually??
    i would be sticking to Outlook express and try getting the SMTP working through that first, what settings have you got in outlook express ? in SMTP Server Pro settings what settings have you put in there ... i noticed on the screen shots that it allows you to put in SMTP gateway settings .... what is in there ?

    once you have outlook express running then you know that it all works and then i would focus on the php code ....

Bookmarks

Posting Permissions

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