Noskiw Posted June 4, 2010 Share Posted June 4, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2010 Share Posted June 4, 2010 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/ Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067964 Share on other sites More sharing options...
Noskiw Posted June 4, 2010 Author Share Posted June 4, 2010 This really overcomplicates things for me. Is there any way that I could send mail without having to use these ridiculous classes and have to apply them? Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067967 Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2010 Share Posted June 4, 2010 Does the host where you are running your php script at provide a mail server and does not require SMTP Authentication? That would be the only way you could use the mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067973 Share on other sites More sharing options...
Noskiw Posted June 4, 2010 Author Share Posted June 4, 2010 I'm using localhost Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067979 Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2010 Share Posted June 4, 2010 You need a public mail server in order to send email to anyone but yourself. If you don't have a public mail server on your system and are using one at an ISP, you must use SMTP Authentication. Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067987 Share on other sites More sharing options...
Noskiw Posted June 4, 2010 Author Share Posted June 4, 2010 But I am using a different email. I'm using googlemail or msn... Quote Link to comment https://forums.phpfreaks.com/topic/203909-mail-problem/#findComment-1067988 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.