Jump to content

[SOLVED] Once file is uploaded to server, Can i get an "Alert Email"


iceman023

Recommended Posts

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

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('[email protected]', 'File Uploaded', $message);

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('[email protected]', 'File Uploaded',  "A file has been uploaded!");

}

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 = '[email protected]';
$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???

 

 

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 = '[email protected]';
$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.

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

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.