Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'phpmailer'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hi, There is a new version of PHPMailer released (v. 5.2.2). It seems this new version is working well with MetYii's wrapper but I can't figure out how to use a great new PHPMailer 'callback' feature. PHPMailer documents it only by example: /* Callback (action) function * bool $result result of the send action * string $to email address of the recipient * string $cc cc email addresses * string $bcc bcc email addresses * string $subject the subject * string $body the email body * @return boolean */ require_once '../class.phpmailer.php'; $mail = new PHPMailer(); function callbackAction ($result, $to, $cc, $bcc, $subject, $body) { /* this callback example echos the results to the screen - implement to post to databases, build CSV log files, etc., with minor changes */ $to = cleanEmails($to,'to'); $cc = cleanEmails($cc[0],'cc'); $bcc = cleanEmails($bcc[0],'cc'); echo $result . "\tTo: " . $to['Name'] . "\tTo: " . $to['Email'] . "\tCc: " . $cc['Name'] . "\tCc: " . $cc['Email'] . "\tBcc: " . $bcc['Name'] . "\tBcc: " . $bcc['Email'] . "\t" . $subject . "<br />\n"; return true; } try { $mail->IsMail(); // telling the class to use SMTP $mail->SetFrom('you@yourdomain.com', 'Your Name'); $mail->AddAddress('another@yourdomain.com', 'John Doe'); $mail->Subject = 'PHPMailer Lite Test Subject via Mail()'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML(file_get_contents('contents.html')); $mail->AddAttachment('images/phpmailer.gif'); // attachment $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment $mail->action_function = 'callbackAction'; $mail->Send(); echo "Message Sent OK</p>\n"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } You can see a callback function and e-mail sending block. When using a wrapper, sending e-mail looks quite similar: Yii::app()->mailer->IsSMTP(); try{ Yii::app()->mailer->Host = Yii::app()->params['mail']['smtp_host']; Yii::app()->mailer->Encoding = Yii::app()->params['mail']['smtp_encoding']; Yii::app()->mailer->CharSet = Yii::app()->params['mail']['smtp_charset']; Yii::app()->mailer->WordWrap = Yii::app()->params['mail']['smtp_word_wrap']; Yii::app()->mailer->From = $model->email; Yii::app()->mailer->FromName = $name; Yii::app()->mailer->AddReplyTo($model->email); Yii::app()->mailer->AddAddress(Yii::app()->params['adminEmail']); Yii::app()->mailer->Subject = $subject; Yii::app()->mailer->getView('contact_form', array('name'=>$model->name, 'email'=>$model->email, 'subject'=>$model->subject, 'body'=>$body), 'main'); Yii::app()->mailer->action_function = 'mailerCallback'; Yii::app()->mailer->Send(); }catch(phpmailerException $e){ Yii::app()->user->setFlash('contact', $e->errorMessage()); }catch(Exception $e){ Yii::app()->user->setFlash('contact', $e->getMessage()); } $this->refresh(); } You may have notice I already added: Yii::app()->mailer->action_function = 'mailerCallback'; but... I have no idea where to put the 'mailerCallback' function within Yii application context. I tried to add it to controller class but it does not work this way. Can you help me please? Rgs, Ziggi
×
×
  • Create New...