我认为您需要一些 javascript 魔法,并且因为您已经使用 HTML5 画布,所以这应该不是问题。
因此,提交按钮上的 onclick 事件将向您的后端 php 邮件脚本发出 ajax 请求。
var strDataURI = oCanvas.toDataURL();
// returns "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACt..."
您只需将 strDataURI 作为参数传递。
现在,我认为您还应该将这些保存在您的数据库中,这样电子邮件中就可以包含这个图像标签:
<img src="http://www.yourdomain.com/generate_image.php?id=2" alt="Design #2" />
generate_image.php 脚本会做这样的事情
<?php
header('Cache-control: max-age=2592000');
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
// connect to db here ..
// $id = (int)$_GET['id']; "SELECT youtable WHERE id = '{$id}'"
// and the $image variable should contain "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACt..."
list($settings, $encoded_string) = explode(',', $image);
list($img_type, $encoding_method) = explode(';', substr($settings, 5))
header("Content-type: {$img_type}");
if($encoding_method == 'base64')
die(base64_decode($encoded_string)); // stop script execution and print out the image
else { // use another decoding method
}