cv使用wp-mail发送电子邮件

时间:2016-05-12 04:56:25

标签: php wordpress

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

上传部分

 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 "";
    }
   }

CV上传成功。

uploadCVFile函数

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

路径设置

 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';
}

现在我想使用wp_mail函数在电子邮件中发送此信息。所有其他数据都成功发送,但我不知道如何处理简历。

邮件功能

if application "Finder" is running then
    tell application "Finder" to activate
end if

1 个答案:

答案 0 :(得分:1)

在SendCareersEmail函数中更改此部分

$cvname="/uploads/cvs/".$_FILES['filecv']['name'];

$attachments = array(
     $cvname
);

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