本文整理汇总了PHP中YiiMailMessage::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP YiiMailMessage::attach方法的具体用法?PHP YiiMailMessage::attach怎么用?PHP YiiMailMessage::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YiiMailMessage
的用法示例。
在下文中一共展示了YiiMailMessage::attach方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRubric
public function actionRubric($id = null)
{
if ($_POST['Form']) {
$model = new Form('new');
$this->performAjaxValidation($model);
$model->attributes = $_POST['Form'];
$model->date = time();
if ($_FILES['file']['tmp_name']) {
$file = CUploadedFile::getInstanceByName('file');
$model->file = $file->getName();
}
if ($model->save()) {
$text = 'Имя: ' . $model->name;
$text .= '<br />Фамилия: ' . $model->lastname;
$text .= '<br />E-mail: ' . $model->email;
$text .= '<br />Телефон: ' . $model->tel;
if ($model->arts) {
$text .= '<br />Артикулы под нанесение: ' . $model->arts;
}
if ($model->delivered) {
$text .= '<br />Желаемая дата заказа: ' . $model->delivered;
}
$text .= '<br />Кол-во цветов: ' . $model->color;
$text .= '<br />Тираж: ' . $model->tirazh;
$text .= '<br />Размеры: ' . $model->width . ' x ' . $model->height;
$text .= '<br />Драг.металы:';
$text .= '<br />Золото - ' . ($model->gold ? 'Да' : 'Нет');
$text .= '<br />Платина - ' . ($model->platina ? 'Да' : 'Нет');
if ($model->text) {
$text .= '<br />Примечание: ' . $model->text;
}
$message = new YiiMailMessage();
$message->setTo(array($this->getConfig('email3') => 'Комплекс Бар'));
$message->setFrom(array($model->email => $model->name . ' ' . $model->lastname));
$message->setSubject('Заказ на нанесение');
$message->setBody($text, 'text/html', 'utf8');
if ($_FILES['file']['tmp_name']) {
$fileNewPath = $_SERVER['DOCUMENT_ROOT'] . '/userdata/nanesenie/' . $file->getName();
$file->saveAs($fileNewPath);
$message->attach(Swift_Attachment::fromPath($fileNewPath));
}
Yii::app()->mail->send($message);
Yii::app()->user->setFlash('message', 'Спасибо за заказ. Наш менеджер свяжется с вами в ближайшее время.');
} else {
$this->render('rubric', $data);
}
$this->refresh();
}
$rubric = Rubrics::model()->findByPk($id);
$data = array('rubric' => $rubric);
$this->render('rubric', $data);
}
示例2: sendMail
protected function sendMail($to, $subject, $body, $att = null)
{
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setBody($body);
$message->subject = $subject;
$message->addTo($to);
$message->from = Yii::app()->params['adminEmail'];
if ($att) {
$swiftAttachment = Swift_Attachment::fromPath($att);
$message->attach($swiftAttachment);
}
return Yii::app()->mail->send($message);
}
示例3: actionMailTes
public function actionMailTes()
{
$message = new YiiMailMessage();
$message->setBody('tes', 'text/html');
$message->setTo('neo_gazebo@yahoo.co.id');
$message->setSubject('tes');
$message->setFrom('admin@dcourier.com');
$html2pdf = Yii::app()->ePdf->HTML2PDF();
$html2pdf->WriteHTML('<p>hehehehe</p>');
$html2pdf->Output(dirname(Yii::app()->basePath) . '/pdf/tes.pdf', EYiiPdf::OUTPUT_TO_FILE);
$message->attach(Swift_Attachment::frompath(dirname(Yii::app()->basePath) . '/pdf/tes.pdf'));
Yii::app()->mail->send($message);
CVarDumper::dump(YiiMail::log($message), 10, true);
}
示例4: sendEmailOrderInfo
public static function sendEmailOrderInfo($params, $pdfFileNames)
{
$msg = new YiiMailMessage();
$msg->view = 'orderInfo';
$msg->setFrom(appParams('adminEmail'), appParams('adminEmailName'))->setTo($params['email'])->setSubject('Заказ номер ' . $params['orderBookingId'] . ' готов');
$msg->setBody($params, 'text/html');
foreach ($pdfFileNames as $key => $pdfInfo) {
$attachment = Swift_Attachment::fromPath($pdfInfo['filename']);
$attachment->setFilename($pdfInfo['visibleName']);
$msg->attach($attachment);
}
Yii::app()->mail->send($msg);
foreach ($pdfFileNames as $key => $pdfInfo) {
if (file_exists($pdfInfo['filename'])) {
unlink($pdfInfo['filename']);
}
}
}
示例5: actionAjaxSendEmailInvoice
public function actionAjaxSendEmailInvoice($id)
{
$email_to = $_POST['email_to'];
$email_to_arr = explode(",", $email_to);
$model = LbInvoice::model()->findByPk($id);
$message = new YiiMailMessage();
$message->subject = $_POST['email_subject'];
$message->setBody($_POST['email_content'], 'text/html');
foreach ($email_to_arr as $value) {
$message->addTo($value);
}
//$message->addTo('thongnv@lionsoftwaresolutions.com');
$message->from = $_POST['email_from'];
$swiftAttachment = Swift_Attachment::newInstance($this->actionPDF($id, true), $model->lb_invoice_no . '.pdf', 'application/pdf');
$message->attach($swiftAttachment);
//$message->AddAttachment(Yii::app()->createAbsoluteUrl('lbInvoice/default/pdf/',array('id'=>$id)));
echo Yii::app()->mail->send($message);
}
示例6: actionMail
public function actionMail($id)
{
try {
$model = $this->loadModel($id);
$address = "";
$dep = array();
$cli = array();
foreach ($model->department->departmentProps as $key => $value) {
$dep[$value['_key']] = $value['_value'];
}
foreach ($model->client->clientProps as $key => $value) {
$cli[$value['_key']] = $value['_value'];
if ($value['_key'] == "email") {
$address = $value['_value'];
}
}
if (strlen($address) == 0) {
$this->renderText('У заказчика нет email адреса');
return;
}
$html2pdf = Yii::app()->ePdf->HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(1, 1, 1, 1));
$html2pdf->WriteHTML($this->renderPartial('prn_pdf', array('dep' => $dep, 'cli' => $cli, 'model' => $model), true));
$filename = "exp_" . Yii::app()->user->uid . "_" . $model->department_id . "_" . $model->name . "_" . $model->client_id . ".pdf";
$html2pdf->Output(Yii::app()->params['load_xml_pdf'] . $filename, 'F');
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setBody("<h2>Добрый день</h2>Просим проверить счет. <br>" . " Если согласны, то просим прислать платежное поручение.<br>" . "<i>C уважением, Отдел продаж.</i>", 'text/html');
$message->subject = "Счет №" . $model->name . " от " . $model->department->name . " для " . $model->client->name;
$message->addTo($address);
$message->addTo(Yii::app()->params['adminEmail']);
$message->from = Yii::app()->params['adminEmail'];
$pathto = Yii::app()->params['load_xml_pdf'] . $filename;
$swiftAttachment = Swift_Attachment::fromPath($pathto);
$message->attach($swiftAttachment);
$res = Yii::app()->mail->send($message);
if ($res) {
$this->renderText('Отправлена почта. Файл:' . $filename);
} else {
$this->renderText('Не отправлена почта');
}
} catch (Exception $ex) {
$this->renderText('Не отправлена почта:' . $ex);
}
}
示例7: actionAjaxSendEmailQuotation
function actionAjaxSendEmailQuotation($id)
{
$email_to = $_POST['email_to_quotation'];
$email_to_arr = explode(",", $email_to);
$model = LbQuotation::model()->findByPk($id);
$message = new YiiMailMessage();
$message->subject = $_POST['email_subject_quotation'];
$message->setBody($_POST['email_content_quotation'], 'text/html');
foreach ($email_to_arr as $value) {
$message->addTo($value);
}
//$message->addTo('thongnv@lionsoftwaresolutions.com');
$message->from = $_POST['email_from_quotaiton'];
$swiftAttachment = Swift_Attachment::newInstance($this->actionPDFQuotation($id, true), $model->lb_quotation_no . '.pdf', 'application/pdf');
$message->attach($swiftAttachment);
//$message->AddAttachment(Yii::app()->createAbsoluteUrl('lbInvoice/default/pdf/',array('id'=>$id)));
if (Yii::app()->mail->send($message)) {
$status = $this->actionAjaxUpdateStatus($id, LbQuotation::LB_QUOTATION_STATUS_CODE_SENT);
$response['lb_quotation_status'] = $status;
LBApplication::renderPlain($this, array('content' => CJSON::encode($response)));
}
}
示例8: xmail
/**
* Send mail function
* @param string $body Mail content
* @param string $toAddress Address (one or many) for send mail to
* @param string $from Sender address. Default value is SETTINGS_ADMIN_EMAIL param
* @param bool $htmlFormat true for HTML, false for plain text
*
* @return bool Send mail result
*/
function xmail($subject, $body, $toAddresses, $from = '', $htmlFormat = true, $files = null)
{
// Set default value for $from if empty
if (empty($from)) {
$from = SETTINGS_ADMIN_EMAILS;
}
$message = new YiiMailMessage();
$contentType = 'text/html';
if (!$htmlFormat) {
$contentType = 'text/plain';
}
$message->setBody($body, $contentType);
$message->subject = $subject;
$toAddrs = explode(',', $toAddresses);
foreach ($toAddrs as $to) {
$message->addTo($to);
}
$message->from = $from;
if ($files != null && is_string($files)) {
$files = array($files);
}
if (is_array($files)) {
foreach ($files as $file) {
$message->attach(Swift_Attachment::fromPath($file));
}
}
return Yii::app()->mail->send($message);
}