dswe30290 2010-08-02 06:25
浏览 35
已采纳

php:ftp-upload成功后发送邮件?

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 = "do-not-reply@mypage.com";
            $EmailTo = "myemail@mypage.com";
            $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 . "
";
            $email_header .= "Content-Type: text/plain; charset=UTF-8
";
            $email_header .= "Reply-To: " . $EmailFrom . " 
";
            $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条回答 默认 最新

  • dtyw10299 2010-08-02 06:37
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退