2013-01-09 66 views
0

我有一個用戶粘貼打印屏幕圖像(僅適用於Firefox)的CKEditor 3.6.5(修訂版7647)字段(在CakePHP 2.2.1網站上)。
通過粘貼(從字按鈕粘貼)生成的HTML是這樣的:printscreen> ckeditor> CakePHP CakeEmail

<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" /> 

在某一點上我必須通過電子郵件對這些領域的巫HTML發送應包括圖像。

閱讀[base64-encoded-images-in-email-signature] [1]和[如何在電子郵件中嵌入圖像] [2]我認爲電子郵件應該與圖像有附件。

我的問題是如何轉換文件上的圖像的src?這樣我打算在發送之前轉換HTML。

我已經成功嘗試附加文件有:

$data = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==');//file_get_contents('http://' . env('HTTP_HOST') . $fileInfo['url'] . '/disable-auth-key:' . Configure::read('Security.salt') . '.' . $fileInfo['ext']); 
$handle = fopen(TMP . 'print_screen.png', 'w+'); 
fwrite($handle, $data); 
fclose($handle); 

$email = new CakeEmail(array(
    'log' => true, 
    'config' => 'smtp', 
    'returnPath' => '[email protected]', 
    'from' => array('[email protected]' => 'APP'), 
    'to' => array('[email protected]' => 'Name'), 
    'emailFormat' => 'html', 
    'subject' => 'image test', 
    'domain' => '@uab.pt', 
    'attachments' => array(
     'print_screen.png' => array(
      'file' => TMP . 'print_screen.png', 
      'mimetype' => 'image/png', 
      'contentId' => 'Print-Screen-01' 
     ) 
    ) 
)); 

$email->send('test|<img src="cid:[email protected]">|'); 

Gmail上我有機會到附件文件,但對身體沒有圖像。哪裏是源

<div id=":85x">test|<img>|</div> 

在Outlook中,沒有附件和源是

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">test|<img src="cid:[email protected]"> 

我也持開放的態度達到同樣結果的其它解決方案。

+0

您可以創建在Webroot公司的形象,只是張貼在電子郵件 – noslone

+0

一個圖像的鏈接@noslone謝謝:圖像不應該是公開的,在我的案例(在我的問題上缺少的要求);這個解決方案也可以工作,但是在許多郵件客戶端,讀者必須授權下載文件(至少第一次)才能看到它們;如果這是個問題,可以發送更小的電子郵件 – jplfl

回答

1

對圖像標籤的src屬性的cid值應該是我使用的@。

正確的代碼行

$email->send('test|<img src="cid:Print-Screen-01">|');