Jump to content

Send an email when file is uploaded


Elusid

Recommended Posts

Ok how can I get my site to send me an email when a new file is uploaded with one of my uploaders? I have several uploaders on my site and I want it so when the user uploads the files it will send me an email saying that they have uploaded it and give me the URL to the folder where it was uploaded. It makes is a lot easer then having to go through the site looking all the time. Thanks!
Link to comment
https://forums.phpfreaks.com/topic/16588-send-an-email-when-file-is-uploaded/
Share on other sites

Ok so I tried this code

[code]
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('[email protected]', 'My Subject', $message);
?>
[/code]

and uploaded it to my server. When I go to the url of the file it's a while screen, no error, and I don't get an email. How do I get this to work right?
@redarrow,

perhaps you should re-read the manual. Nothing wrong with Elusid's wordwrap() call.

[code]<?php
$text = "This is the text to word wrapped so the lines are a maximum length of twenty characters";
echo '<pre>', wordwrap($text, 20), '</pre>';
?>[/code]

gives -->
[pre]This is the text to
word wrapped so the
lines are a maximum
length of twenty
characters
[/pre]
mail returns a boolean value, use if/else to check its status. Also set your error reporting to error_reporting(E_ALL); <-- this has saved me already a lot of time/problems


[code]
if (mail(..)) {
// mail success
} else {
// mail problem...
}
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.