日期:2014-05-16  浏览次数:20669 次

使用邮件发送linux下快照截图
命令行截图
/home/zengwenjie/wkhtmltoimage-i386 www.baidu.com /home/myaccountbaidu.png
/usr/local/imagemagick/bin/convert /home/myaccount/baidu.png /home/myaccount/baidu.jpg
发现中文是乱码
解决办法:
找了windows里的宋体
上传到服务器/usr/share/fonts/里


/usr/share/fonts/chinese/TrueType/simsun.ttc

 邮件配图

<?php
	header ("Content-Type:text/html;charset=utf-8");


$email_from = "admin@xxx.com"; // Who the email is from
$email_subject = "Statement of Account - SENTEC"; // The Subject of the email
 
$email_to = "myaccount@xxx.com"; // Who the email is too
$cc = "myaccount@xxx.com";
$picurl = "http://www.baidu.com";
$picname= "admin";
$email_txt = "我是一个兵<br><img src='".$picname.".jpg'>";

F_sent_mul_mail($picurl,$picname,$email_from,$email_to,$cc,$email_subject,$email_txt );


function F_sent_mul_mail($picurl,$picname,$email_from,$email_to,$cc,$email_subject,$email_txt)
{
	$cmd = "/data/crontab.d/wkhtmltoimage-i386 \"".$picurl."\" /data/crontab.d/pic/".$picname.".png"; `$cmd`;
	$cmd = "/usr/local/imagemagick/bin/convert /data/crontab.d/pic/".$picname.".png /data/crontab.d/pic/".$picname.".jpg"; `$cmd`;
	$a_file_path = "/data/crontab.d/pic/".$picname.".jpg"; // Path to the file

	 $fileatt_type = "application/octet-stream"; // File Type
	 $fileatt_name =  $picname.".jpg";
	 
	 $config = "admin@xxx.com";

	 $semi_rand = md5(time());
	 $mime_boundary = "==Mix_Multipart_Boundary_x{$semi_rand}x";

	$part_boundary = "==Alt_Multipart_Boundary_x{$semi_rand}x";

	 $headers = "MIME-Version: 1.0" . "\r\n";
	 $headers .= "Content-type:text/html;charset=utf-8" . "\r\n";  
	 $headers .= 'Cc: '.$cc. "\r\n";

	 $headers .= "From: ".$email_from;

	 $headers .= "\nMIME-Version: 1.0\n" .
	 "Content-Type: multipart/mixed;\n" .
	 " boundary=\"{$mime_boundary}\"";
	 $file = fopen($a_file_path,'rb');
	 $data = fread($file,filesize($a_file_path));
	 fclose($file);
	 $data = chunk_split(base64_encode($data));

	 $email_message  = "--{$mime_boundary}\n" .
	 "Content-Type: multipart/alternative; boundary=\"{$part_boundary}\"\n";

	 $email_message .= "\n\n" .
	 "--{$part_boundary}\n" .
	 "Content-Type:text/plain; charset=\"utf-8\"\n" .
	 "Content-Transfer-Encoding: 7bit\n\n" .
	 $email_txt . "\n\n";

	 $email_message .= "\n\n" .
	 "--{$part_boundary}\n" .
	 "Content-Type:text/html; charset=\"utf-8\"\n" .
	 "Content-Transfer-Encoding: 7bit\n\n" .
	 $email_txt . "\n\n";

	 $email_message .= "--{$part_boundary}--\n";
	 $email_message .= "--{$mime_boundary}\n" .
	 "Content-Type: {$fileatt_type};\n" .
	 " name=\"{$fileatt_name}\"\n" .
	 "Content-Transfer-Encoding: base64\n\n" .
	 $data . "\n\n".
	 "--{$mime_boundary}\n";
 
	 $ok = @mail($email_to, $email_subject, $email_message, $headers, $config);
	 if($ok) 
	 {
	  echo "<font face=verdana size=2>The file was successfully sent!</font>";
	 }
	 else
	 {
	  die("Sorry but the email could not be sent. Please go back and try again!");
	 }
}
?>