Jump to content

mail()


coolgamer48
 Share

Recommended Posts

Hey.Okay - so I have this page that utilizes the mail() function.mail() returns true, but I don't recieve an email in my inboxI know you need some program installed on the server, but if I didn't have it on mine (awardspace.com), wouldn't the mail() function return false?Anyone know what's going on?Live: http://alecbenzer.awardspace.com/sendme_file.phpSource:

<html>	<head>		<title>Alec Benzer - Send Me a File</title>		<link rel = "stylesheet" type = "text/css" href = "stylesheet.css" />	</head>	<body>		<table width = "100%" cellpadding = "20" cellspacing = "0">			<tr>				<?php include("header.php"); ?>			</tr>			<tr>				<?php include("sidebar.php");?>				<?php include("maintd_pre.php");?>					<h1>Send Me a File</h1>					Hey, do you ever just get the urge to send someone a random file? I know I do. Well, while most people would force you to email them the file the old boring way, I took the liberty of creating a page for it. Just upload your files here.					<h2>File Upload</h2>					<form action = "sendme_file.php" method = "post" enctype = "multipart/form-data">					<table>						<tr>							<td>File:</td><td><input type = "file" name = "file" /></td><br />						</tr>						<tr>							<td>Email:</td><td><input type = "text" name = "email" /></td><br />						</tr>						<tr>							<td colspan = "2"><input type = "submit" value = "Upload" /></td>						</tr>					</table>					</form>					<?php						if ($_FILES["file"]["size"] > 0)						{							if ($_FILES["file"]["size"] > 20000)							{								echo "<br />".$_FILES["file"]["name"]." is too large. Maximum upload size is 20KB.";							}							elseif ($_FILES["file"]["type"] != "image/jpeg" && $_FILES["file"]["type"] != "image/bmp" && $_FILES["file"]["type"] != "text/plain" && $_FILES["file"]["type"] != "image/gif")							{								echo $_FILES["file"]["type"]." is not a supported file type. You may only upload JPEG, GIF, or BMP image files, or plain text files.";							}							elseif ($_FILES["file"]["error"] > 0)							{								echo "<br />".$_FILES["file"]["name"]." could not succesfully upload. Error: ".$_FILES["file"]["error"];							}							elseif (file_exists("uploads/send_me_".$_FILES["file"]["name"]) == TRUE)							{								echo "<br />".$_FILES["file"]["name"]." already exists.";							}							elseif (move_uploaded_file($_FILES["file"]["tmp_name"],"uploads/send_me_".$_FILES["file"]["name"]) == FALSE)							{								echo "<br />".$_FILES["file"]["name"]." could not upload.";							}							else							{								echo "<br />".$_FILES["file"]["name"]." uploaded succesfully.";								if (mail($_REQUEST["email"],"Your file was uploaded!","Congratulations!\n\nYour file ".$_FILES["file"]["name"]." was uploaded succesfully.") == TRUE)								{									echo "<br />A confirmation email was sent to ".$_REQUEST["email"];								}							}						}					?>				</td>			</tr>			<tr>				<?php include("footer.php");?>			</tr>		</table>	</body></html>

lol - codebox is too big - don't know whyif you guys try to upload, only jpg, bmp, gif, or txt files under 20k will work

Link to comment
Share on other sites

Well, it could be that your E-mail was sent correctly but the given address was wrong. It could also be that something is blocking the E-mail after it gets sent.Awardspace may have the mail() function disabled, I don't know if mail() would still return false or not if that happened. As a last resort you can ask them.

Link to comment
Share on other sites

First, you need a hidden input for your upload form for the max size. Check the reference on php.net for examples:http://www.php.net/manual/en/features.file-upload.phpThen, you have your email line here:if (mail($_REQUEST["email"],"Your file was uploaded!","Congratulations!..."))One thing is you will want to validate the email address. There's a thread in the PHP forum that just got posted yesterday about exploiting the mail function, read through that for an explanation. You might also need a From address with the email. You can add that in a header. Also check with awardspace to see what their policies about using PHP to send email are, they might have specific rules you need to follow (such as the domain in the from address).http://www.php.net/manual/en/function.mail.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...