使用wp邮件发送简历


cv sending in email using wp-mail

我成功地从职业页面上传了一份简历。现在我想通过电子邮件发送这个。

上传部分

 if ($_FILES['filecv']['name'] != "") {
        $sqldata['att_ment'] = uploadCVFile($_FILES['filecv']);
    } else {
        $sqldata['att_ment'] = '';
    }

简历上传成功。

上传CVFile功能

 function uploadCVFile($uploadedfile)
 {
    if (!function_exists('wp_handle_upload'))
    require_once (ABSPATH . 'wp-admin/includes/file.php');
    $upload_overrides = array('test_form' => false);
    add_filter('upload_dir', 'cv_uploads_dir');
    $movefile = wp_handle_upload($uploadedfile, $upload_overrides);
    remove_filter('upload_dir', 'cv_uploads_dir');
    if ($movefile) {
        return basename($movefile['file']); //$uploadedfile['name'];
    } else {
         return "";
    }
   }

路径集

  function cv_uploads_dir($param)
  {
    $param['subdir'] = '/cvs';
    $param['path'] = $param['basedir'] . $param['subdir'];
    $param['url'] = $param['baseurl'] . $param['subdir'];
    return $param;
  }

现在我想使用wpmail函数通过电子邮件发送这个消息。所有其他数据都发送成功,但我不知道如何处理简历。

邮件功能

 function SendCareers_Email($pst)
{
$to = get_option('career_email');
$from = $pst['e-mail'];
$name = $pst['firstname'];
$cvname="/uploads/cvs/".$sqldata['att_ment'];
$subject = "Applying for the job " . $pst['title'];
$message= "Candidate Name:-" . $name . "<br/>";
$message .= "Job Title Applied:-" . $pst['title'] . "<br/>";
if(!empty($pst['country'])){
$message .= "Country Of Resindency:-" . $pst['country'] . "<br/>";
}
if(!empty($pst['nationlaity'])){
$message .= "Nationlaity:-" . $pst['nationlaity'] . "<br/>";
}
$attachments = array( WP_CONTENT_DIR . $cvname );
if(!empty($pst['mobileno'])){
$message .= "Phone Number:-" . $pst['mobileno'] . "<br/>";
}
add_filter('wp_mail_content_type', 'set_career_html_content_type');
$admin_headers = 'From: '.$name.' <'.$from .'>' . "'r'n''";
wp_mail($to, $subject,$message ,  $admin_headers,$attachments);
remove_filter('wp_mail_content_type', 'set_career_html_content_type'); 
}
function set_career_html_content_type()
{
    return 'text/html';
}

在SendCareersEmail功能中更改此部分

$cvname="/uploads/cvs/".$_FILES['filecv']['name'];
$attachments = array(
     $cvname
);

在函数内部时,只有全局变量或传递到函数中的变量(在您的情况下为$pst)可用。因此,要么将$sqldata传递给函数SendCVEmail($pst,$sqldata),要么使用$_FILES['filecv']['name']的全局调用