iceman023 Posted June 21, 2009 Share Posted June 21, 2009 I was just wondering, is there anyway i can get an email once someone has uploaded a file to my server, just to let me know that there's activity. Maybe something like a hidden submit button to send an email or something. Any ideas would be great... Thanks Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 21, 2009 Share Posted June 21, 2009 user the mail function http://au2.php.net/manual/en/function.mail.php .. put something like this in your code after the file has been uploaded $message = "A file has been uploaded!"; mail('yourEmail@yourDomain.com', 'File Uploaded', $message); Quote Link to comment Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 where would i put that tho..? Maybe in the value of a hidden submit button, Onclick, Function, or Action?? Quote Link to comment Share on other sites More sharing options...
pkedpker Posted June 21, 2009 Share Posted June 21, 2009 pretty simple.. if you use a POST method form.. when a file is done uploading it will trigger a $_POST['submit'] then after it triggers you can use a IF Statment where you know.. you put the filename into mysql or whatever.. if(isset($_POST['submit'])) { mail('yourEmail@yourDomain.com', 'File Uploaded', "A file has been uploaded!"); } Quote Link to comment Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 Ok thanks very much i got it to work. Now after doing some research i want to make the email look better.. I did an include command to call a new page called alertemail.php. This time im getting an error Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in *****alertemail.php on line 23 <?php { $to = 'myemailaddress@abc.com'; $subject = 'Activity'; $message = ' <html> <head><title></title> </head> <body> <center> <p>A file has been uploaded to your site!</p> <p><a href="admin.php">Click here to go to admin</a></p> <p><img src="photo1.jpg" width="144" height="36"></p> </center> </body></html> '; $message = wordwrap($message, 70); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $headers); } ?> What do you think the problem is??? Quote Link to comment Share on other sites More sharing options...
pkedpker Posted June 21, 2009 Share Posted June 21, 2009 Ok thanks very much i got it to work. Now after doing some research i want to make the email look better.. I did an include command to call a new page called alertemail.php. This time im getting an error Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in *****alertemail.php on line 23 <?php { $to = 'myemailaddress@abc.com'; $subject = 'Activity'; $message = ' <html> <head><title></title> </head> <body> <center> <p>A file has been uploaded to your site!</p> <p><a href="admin.php">Click here to go to admin</a></p> <p><img src="photo1.jpg" width="144" height="36"></p> </center> </body></html> '; $message = wordwrap($message, 70); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $message, $headers); } ?> What do you think the problem is??? try replacing the message with this $message = '\r\n <html>\r\n <head><title></title>\r\n </head>\r\n <body>\r\n <center>\r\n <p>A file has been uploaded to your site!</p>\r\n <p><a href="admin.php">Click here to go to admin</a></p>\r\n <p><img src="photo1.jpg" width="144" height="36"></p>\r\n </center>\r\n \r\n </body></html>\r\n '; no guarantees that will do anything. Quote Link to comment Share on other sites More sharing options...
iceman023 Posted June 21, 2009 Author Share Posted June 21, 2009 Yes thank you, i have fix that error now.. Now everything looks good but i want a link within the email.. The problem is, is that it just appears as text "NO LINK" I echoed out $messages and opened the page in a browser and the link works there. Just not in an email. Why do you think this is.. Quote Link to comment 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.