2009-07-06 33 views

Trả lời

2

i viết wrapper cho lớp tử

private function _processHtmlBody($I_html, $I_mailer, $I_data) { 

$html = $I_html; 
$mail = $I_mailer; 

$xmlBody = new DomDocument(); 
$xmlBody->loadHTML($html); 

$imgs = $xmlBody->getElementsByTagName('img'); 
$I_data['atts'] = array(); 

$imgCount = 0; 
foreach ($imgs as $img) { 
    $imgCount++; 
    $imgUrlRel = $img->getAttribute('src'); 

    $imgId = sha1(time() . $imgCount . $imgUrlRel); 
    $html = str_replace($imgUrlRel, 'cid:' . $imgId, $html); 

    $imgUrlFull = 'http://' . $_SERVER['HTTP_HOST'] . $imgUrlRel; 

    $imgBinary = file_get_contents($imgUrlFull); 

    $imgPart = $mail->createAttachment($imgBinary); 

    $imgPart->filename = 'image' . $imgCount . '.jpg'; 
    $imgPart->id = $imgId; 

    $I_data['atts'][] = $imgPart; 
    } 
    $mail->setBodyHtml($html); 

    return $html; 
} 
Các vấn đề liên quan