tags:

views:

23

answers:

1

hey guys, i wonder what i'm doing wrong? I'm working on a ftp-upload with php. if files are uploaded successfully i want to get a confirmation email. just a simple email.

if my connection to the FTP Server was a success i'm calling the sendmail() function! it's not working!

        function sendmail() {
            $EmailFrom = "[email protected]";
            $EmailTo = "[email protected]";
            $Subject = "File uploaded to your FTP Server";
            $Body = "Howdy, files have just been transferred to your Server.";
            // Email Headers with UTF-8 encoding
            $email_header = "From: " . $EmailFrom . "\r\n";
            $email_header .= "Content-Type: text/plain; charset=UTF-8\r\n";
            $email_header .= "Reply-To: " . $EmailFrom . " \r\n";
            $success = mail($EmailTo, $Subject, $Body, $email_header);
            if ($success){
              print "success with EMAIL";
            }
            else{
              print "error with EMAIL";
            }
        }

any idea what i'm doing wrong here? does the $EmailFrom value have to be an actual Emailaddress? It's just not working. Neither success nor error gets printed out. And nothing of my code AFTER the function-call gets executed.

thank you for your help

+1  A: 

Well if you want to sendmail() when ftp upload is success do something like this

$status = move_uploaded_file($src,$destination);
if($status) { sendmail(); }

What this will do this, first $status will hold the boolean value whether the upload is successful, and if it suceeds then it will call your sendmail() function

Starx