0

我有一个 php 网站。在这里我有表格上传用户的简历(必须在一个世界文件中),并将这个文件和用户信息邮寄给管理员。我使用了 PHP4 邮件功能。

我将如何使用这个附加的世界文件编写 php 邮件功能

请回复

提前致谢

4

2 回答 2

1

像这样的东西?

  function attachdir(){

 $dir = 'uploaded_photos/';//resume folder
        // save pdf in directory
        $pdf->Output($dir . $filename);// filename of the document
        $data = $pdf->Output("", "S");
        $usersubname  = $this->input->get('userName');
        $userid       = $this->input->get('userId');
        $LeaderId = $this->input->get('LeaderId');
        $pass         = $this->input->get('password');
        $to           = $this->input->get('email');
        $this->smtpmailer($to, $usersubname, $dir, $filename, $userid, $LeaderId, $pass);
        unlink($dir . $filename);

    }


    function smtpmailer($to, $usersubname, $dir, $filename, $userid, $LeaderId, $pass)
    {
        $subject = $userid;
        $message = '<html><body>';

        $message .= "Hello  , <br><br>";
        $message .= "$usersubname,hii, resume attached along with this mail";
        $message .= "</body></html>";


        //$mailDetials  =   $this->adminmodel->mailDetials();
        $adminusername = 'XXXXXXXXXXXX';
        $adminpassword = 'XXXXXXXXXXXX';
        $adminhost     = "stmp.gmail.com";
        $adminport     = 465;
        $adminmail     = 'XXXXXXXXXXXX@gmail.com';
        $adminEmail    = 'XXXXXXXXXX@gmail.com';
        $to            = $to;


        require_once('./phpmailer/class.phpmailer.php');
        global $error;
        $mail = new PHPMailer(); // create a new object
        $mail->IsSMTP(); // enable SMTP
        $mail->Mailer     = "smtp";
        $mail->Host       = "smtp.gmail.com";
        $mail->SMTPSecure = "ssl"; //ssl or tls
        $mail->SMTPDebug  = 1; // debugging: 1 = errors and messages, 2 = messages only
        $mail->SMTPAuth   = true; // authentication enabled
        $mail->Port       = $adminport;
        $mail->Username   = $adminusername;
        $mail->Password   = $adminpassword;
        $mail->SetFrom($adminmail, 'XXXXXXXXXXXXX');
        $mail->Subject = $subject;
        $mail->IsHTML(true);
        $mail->Body = $message;
        $mail->AddAddress($to);
        $mail->AddBCC($to, "member");
        $mail->AddCC($adminEmail, "admin");
        $mail->AddAttachment($dir . $filename);//**attachment is done over here**
        //$mail->AddBCC($to, "member");
        if ($mail->Send()) {
            ob_start(); // ensures anything dumped out will be caught
            while (ob_get_status()) {
                ob_end_clean();
            }


        } else {
            //  echo 'Not sent: <pre>'.print_r(error_get_last(), true).'</pre>';

        }



    }
于 2012-07-12T05:28:14.727 回答
0

我正在使用 PHP Mailer 库来帮助我发送带有附件的电子邮件http://code.google.com/a/apache-extras.org/p/phpmailer/

它有 AddAttachment() 方法,可以帮助您发送附件。

于 2012-07-12T05:26:30.577 回答