Jump to content

My Mailer not's working


nathanmaxsonadil

Recommended Posts

do you know what's a matter with this mailer?

It does not give me any erorr's but it wont send the email :(

 

register.php

 

here's the mailing part

$send = mail($email , "Registration Confirmation" , "Thank you for registering with YourWebsite.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://swapinvites.com/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks", "FROM: noreply@swapinvites.com");

and here's the whole code

<?php

include 'config.php';

if(isset($_POST['submit']))
{

$first = addslashes(trim($_POST['firstname']));
$surname = addslashes(trim($_POST['surname']));
$username = addslashes(trim($_POST['username']));
$email = addslashes(trim($_POST['email']));
$pass = addslashes(trim($_POST['password']));
$conf = addslashes(trim($_POST['confirm']));

$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d, m y");

if ( $_POST['password'] == $_POST['confirm'] )
{}else{

	echo '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
	echo '<script>history.back(1);</script>';
	exit;

}

$password = md5($pass);

if ((((( empty($first) ) || ( empty($surname) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) )))))
{

	echo '<script>alert("One or more fields was left empty, please try again.");</script>';
	echo '<script>history.back(1);</script>';
	exit;

}

if((!strstr($email , "@")) || (!strstr($email , ".")))
{

	echo '<script>alert("You entered an invalid email address. Please try again.");</script>';
	echo '<script>history.back(1);</script>';
	exit;

}

$q = mysql_query("SELECT * FROM Users WHERE Username = '$username'") or die(mysql_error());
if(mysql_num_rows($q) > 0)
{

	echo '<script>alert("The username you entered is already in use, please try again.");</script>';
	echo '<script>history.back(1);</script>';
	exit;

}

$name = $first . ' ' . $surname;
$actkey = mt_rand(1, 500).'f78dj899dd';
$act = sha1($actkey);

$query = mysql_query("INSERT INTO Users (Username, Password, Name, Email, Date, IP, Actkey) VALUES ('$username','$password','$name','$email','$date','$ip','$act')") or die(mysql_error());
$send = mail($email , "Registration Confirmation" , "Thank you for registering with YourWebsite.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://swapinvites.com/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks", "FROM: noreply@swapinvites.com");

if(($query)&&($send))
{

	echo '	<html>
			<head>
			<title>Success</title>
			<link href="style.css" rel="stylesheet" type="text/css">
			</head>

			<body>

			<div id="success">
			<p>Thank you for registering, you will recieve an email soon with your login details and your activation link so that you can activate your account.</p>
			<p><a href="login.php">Click here</a> to login once you have activated.</p>
			</div>

			</body>
			</html>
			';	

} else {

	echo '
			<html>
			<head>
			<title>Error</title>
			<link href="style.css" rel="stylesheet" type="text/css">
			</head>

			<body>

			<div id="error">
			<p>We are sorry, there appears to be a problem with our script at the moment.</p>
			<p>Your data was not lost. Username: '.$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'</p>
			<p>Please try again later.</p>
			</div>

			</body>
			</html>
			';	

}

} else {

?>
<html>
<head>
<title>Register</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">the registration page</div>
<br>
<div id="main"> 
  <p>Welcome to the registration, fill out the form below and hit Submit. All fields are required,so fill them all out! </p>
  <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
	<tr class="firstRow">
	  <td width="50%">First name </td>
	  <td width="50%"><input name="firstname" type="text" class="textBox" id="firstname"></td>
	</tr>
	<tr class="secondRow">
	  <td>Surname</td>
	  <td><input name="surname" type="text" class="textBox" id="surname"></td>
	</tr>
	<tr class="firstRow">
	  <td>Email Address </td>
	  <td><input name="email" type="text" class="textBox" id="email"></td>
	</tr>
	<tr class="secondRow">
	  <td>Username</td>
	  <td><input name="username" type="text" class="textBox" id="username"></td>
    </tr>
	<tr class="firstRow">
	  <td>Password</td>
	  <td><input name="password" type="password" class="textBox" id="password"></td>
	</tr>
	<tr class="secondRow">
	  <td>Confirm Password </td>
	  <td><input name="confirm" type="password" class="textBox" id="confirm"></td>
	</tr>
	<tr class="firstRow">
	  <td>Register</td>
	  <td><input name="submit" type="submit" class="textBox" value="Submit"></td>
	</tr>
  </table>
  </form>
  Upon confirmation of your details, you will be sent an email containing your username, password and details on how to activate your account so as to be able to use this website. </div>

</div>

</body>
</html>

<? } mysql_close($l); ?>

 

P.S sorry for the messup

Link to comment
Share on other sites

This is a registration script, but okay..

Try making the mail function shorter, by putting the message as a variable it could reduce conflict.

/* The message put as an variable. */
$message = "Thank you for registering with YourWebsite.\n\n";
$message .= "Your username and password is below, along with details on how to activate your account.\n\n";
$message .= "User: ".$username."\nPass: ".$pass."\n\n";
$message .= "Click the link below to activate your account:\n";
$message .= "http://swapinvites.com/activate.php?id=".$act."\n\n";
$message .= "Please do not reply, this is an automated mailer.\n\nThanks";
/* The headers as an variable. */
$headers = "From: noreply@swapinvites.com";
/* Subject as an variable. */
$subject = "Registration Confirmation";
$send = mail($email, $subject, $message, $headers);

 

Try that combination.

Link to comment
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.