function SaeMailSendHtml($ToAddress, $Title = '', $HtmlContent = '', $AttachFile = array()) { $mail = new SaeMail(); if (is_array($AttachFile) && $AttachFile !== array()) { $mail->setAttach($AttachFile); } $mail->setOpt(array("content_type" => "HTML")); $result = $mail->quickSend($ToAddress, $Title, $HtmlContent, Sae_Mail_From_Address, Sae_Mail_From_Password); return $result; //示例代码: //var_dump(SaeMailSendHtml('*****@*****.**','标题','<A href="http://www.moonlord.cn">正文</A>',array( '附件.txt' => '这里是附件的二进制数据' , '附件.png' =>file_get_contents("https://www.baidu.com/img/bdlogo.png") ))); }
public function attachmail() { $a = 0; if (!empty($_FILES)) { // // var_dump($_FILES); import("@.ORG.UploadFile"); $config = array('allowExts' => array('jpg', 'gif', 'png'), 'savePath' => './Public/upload/', 'saveRule' => 'time'); $upload = new UploadFile($config); $upload->imageClassPath = "@.ORG.Image"; $upload->thumb = true; $upload->thumbMaxHeight = 100; $upload->thumbMaxWidth = 100; if (!$upload->upload()) { $this->error($upload->getErrorMsg()); } else { $info = $upload->getUploadFileInfo(); $this->assign('filename', $info[0]['savename']); //模版引用变量{$filename} //$GLOBALS['image'] = $info[0]['savename']; //抓 取 图 像 $f = new SaeFetchurl(); // var_dump($info[0]['savename']); // var_dump($info); // var_dump($a); $img_data = $f->fetch("http://thinkfortest-public.stor.sinaapp.com/upload/" . $info[0]['savename']); $img = new SaeImage(); $img->setData($img_data); $new_data = $img->exec(); //var_dump($new_data); $a = 1; } } if (isset($_POST['sub1'])) { $subject = $_POST['subject']; $content = $_POST['content']; //现在暂不支持gmail邮箱和附件上传,建议使用新浪邮箱测试。注意需要开启你邮箱的smtp功能。 /* $f = new SaeFetchurl(); var_dump($GLOBALS['image']); var_dump($a); $img_data = $f->fetch( "http://thinkfortest-public.stor.sinaapp.com/upload/".$GLOBALS['image']); //$img = file_get_contents('http://www.baidu.com/img/bdlogo.png'); //var_dump($img_data); $img = new SaeImage(); $img->setData( $img_data ); $new_data = $img->exec();*/ //var_dump($new_data); $mail = new SaeMail(); if ($a = 1) { $mail->setAttach(array($info[0]['name'] => $new_data)); } $ret = $mail->quickSend('*****@*****.**', $subject, $content, '*****@*****.**', 'wsxhq850687192'); if ($ret === false) { var_dump($mail->errno(), $mail->errmsg()); } else { echo "邮件发送成功!"; } } $this->display(); }