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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料