Jump to content

Recommended Posts

The error

 

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. z33sm13011621wbd.13 in C:\xampp\htdocs\projects\p_web\include\reg.php  on line 54

 

The code

 

<?php

$submit = $_POST['submit'];

$id = $_GET['id'];

$firstname = strip_tags($_POST['firstname']);
$lastname = strip_tags($_POST['lastname']);
$email = addslashes(strip_tags($_POST['email']));
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));
$verifypassword = strip_tags($_POST['verifypassword']);
$date = date("Y-m-d");

if($submit){
    if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){        
        if($password == $verifypassword){
            if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){
                echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters";
            }else{
                if(strlen($password)>25||strlen($password)<6){
                    echo "Password must be <b>between</b> 6 and 25 characters!";
                }else{
                    $password = md5($password);
                    $verifypassword = md5($verifypassword);
                    
                    $random = rand(23456789,98765432);

                    $sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')";
                    $res = mysql_query($sql) or die(mysql_error());
                    
                    $lastid = mysql_insert_id();
                    
                    
                    $to = $email;
                    $subject = "Activate your account!";
                    $headers = "From: [email protected]";
                    $server = "smtp.gmail.com";
                    
                    ini_set("SMTP", $server);
                    
                    $body = "
                    
                    Hello $firstname $lastname,\n\n
                    
                    You need to activate your account with the link below...
                    
                    http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n
                    
                    Thanks!
                    
                    ";
                    
                    mail($to, $subject, $body, $headers);
                    
                    echo "Success! Check your email to activate your account!";
                    
                    }
                }
            }
        }else{
            echo "Passwords <b>Do Not Match</b>!";
        }
     }else{
        echo "Please fill in <b>all</b> fields!";
     }


?>

<form action="index.php?p=reg" method="POST"> 
    <table>
        <h1>Register</h1>
        <tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr>
        <tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr>
        <tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr>
        <tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr>
        <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>
        <tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr>
        <tr><td><input type="submit" name="submit" value="Register" /></tr></td>
    </table>
</form>

 

Basically what I am trying to do is to register a user and then make him activate his account through an email. My email account is [email protected] but I have no idea what SMTP or POP3 server to use. If anyone has any clue, please tell me or correct my code? Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/203909-mail-problem/
Share on other sites

The mail server settings - http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

 

Since SMTP Authentication is need (which the php mail() function does not support), you will need to use one of the php mailer classes - http://phpmailer.worxware.com/ or http://swiftmailer.org/

Link to comment
https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067964
Share on other sites

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.