为什么这不给我发电子邮件通知


Why wont this email me a notification

嗨,我刚刚启动并运行了这个视频上传器表单,它运行得很好。然而,我想在我的电子邮件中发出某种通知,让我知道有人刚刚上传了一段视频到我的服务器。但它并没有通知我,我已经完全简化了它,只是为了给我一些信息,但它只是不起作用,我错过了什么`

if(isset($_FILES["FileInput"]) && $_FILES["FileInput"]["error"]== UPLOAD_ERR_OK)
{
$UploadDirectory    = '../video_uploader/uploads/';

if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
    die();
}

//Is file size is less than allowed size.
if ($_FILES["FileInput"]["size"] > 500242880) {
    die("File size is too big!");
}
//allowed file type Server side check
switch(strtolower($_FILES['FileInput']['type']))
    {
        //allowed file types
        case 'image/png': 
        case 'image/gif': 
        case 'image/jpeg': 
        case 'image/pjpeg':
        case 'text/plain':
        case 'text/html': //html file
        case 'application/x-zip-compressed':
        case 'application/pdf':
        case 'application/msword':
        case 'application/vnd.ms-excel':
        case 'video/mp4':
            break;
        default:
            die('Unsupported File!'); //output error
}
$File_Name          = strtolower($_FILES['FileInput']['name']);
$File_Ext           = substr($File_Name, strrpos($File_Name, '.')); 
$Random_Number      = rand(0, 9999999999); //Random number to be added to name.
$NewFileName        = $Random_Number.$File_Ext; //new file name
if(move_uploaded_file($_FILES['FileInput']['tmp_name'], $UploadDirectory.$NewFileName   ))
   {
    die('Success! File Uploaded.');
}else{
    die('error uploading File!');
}
}
else
{
die('Something wrong with upload! Is "upload_max_filesize" set correctly?');
}

mail("me@myemail.com.", $NewFileName);


?>`

试试这个。根据需要更改字段。

$headers  = 'MIME-Version: 1.0' . "'r'n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
$headers .= "To: me@myemail.com" . "'r'n";
$headers .= "From: demo.com <contact@demo.com>" . "'r'n";
mail('me@myemail.com', $subject, $message, $headers);
// subject and message just choose according to your needs and it should be in html format.

为了进一步参考,请遵循以下链接

http://www.w3schools.com/php/php_ref_mail.asp
http://php.net/manual/en/function.mail.php

php mailer不是这样工作的。它需要标题、主题和消息。如果没有合适的标题,电子邮件就不会发送,因为它不知道该去哪里。此外,当你设置好所有内容时:"检查你的垃圾邮件箱"

http://www.w3schools.com/php/php_ref_mail.asp

http://php.net/manual/en/function.mail.php

在本节中再次检查您的代码:

if(move_uploaded_file($_FILES['FileInput']['tmp_name'], $UploadDirectory.$NewFileName   ))    
{
        die('Success! File Uploaded.'); 
}
else
{
        die('error uploading File!'); 
}

所以,如果你的文件上传失败,你的脚本就会死(),并显示一条错误消息
另一方面,如果上传成功,脚本将再次死亡()
这听起来合乎逻辑吗?你的脚本永远不会达到它应该发送电子邮件的地步

此外,正如其他人所建议的那样,mail()函数需要3个参数。