21286 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 268 Views |
-
SS3 + swiftmailer problem, worked with SS2,4

5 October 2012 at 9:26pm
hi,
I have problems with SS3 and swiftmailer.
With SS2.4 there are not any problems, I integrated swiftmailer this way:In /swiftmailer/code are all swiftmailer files
/swiftmailer/_config.php
<?php
require(dirname( __FILE__ )."/code/swift_required.php");
and this is my swiftmailer class to call swiftmailer:
<?php
class SwiftMailer {
private $smtphost;
private $port;
private $user;
private $password;
private $mailer;
private $message;private $textpart;
private $htmlpart;public $sender;
public $receiver;
public $subject;
public $texttemplate;
public $htmltemplate;
public $templatedata;public function __construct() {
$this->smtphost = 'localhost';
$this->port = 25;
$this->user = 'noreply@xxx';
$this->password = 'xxx';$transport = Swift_SmtpTransport::newInstance($this->smtphost, $this->port)
->setUsername($this->user)
->setPassword($this->password);debug::dump($transport);
if(!isset($this->sender)) {
$this->sender = array('noreply@xxx' => 'Sender Name');
}
$this->mailer = Swift_Mailer::newInstance($transport);
$this->message = Swift_Message::newInstance();
}public function send() {
$this->message->setFrom($this->sender);
$this->message->setTo($this->receiver);
$this->message->setSubject($this->subject);if(isset($this->templatedata) && !empty($this->templatedata)) {
$templatedata = new ArrayData($this->templatedata);
} else {
$templatedata = new ArrayData(array());
}$this->textpart = $templatedata->renderWith($this->texttemplate);
$this->message->setBody($this->textpart);
if(isset($this->htmltemplate) && !empty($this->htmltemplate)) {
$this->htmlpart = $templatedata->renderWith($this->htmltemplate);
$this->message->addPart($this->htmlpart,'text/html');
}$result = $this->mailer->send($this->message);
return $result;
}}
as mentioned, this works perfect with ss2.4 but not with ss3, there are serveral swiftmailer errors like this one:
ERROR [Notice]: Undefined variable: buf
IN POST /xxx/inquiry
Line 56 in /var/www/vhosts/xxx/httpdocs/yyy/swiftmailer/code/classes/Swift/Transport/EsmtpTransport.phpso what can be the difference here? any ideas? is there anything changed in SS3 regarding to implementing 3rd party stuff?
thx
-
Re: SS3 + swiftmailer problem, worked with SS2,4

6 October 2012 at 2:49am
I now use Zend_Mail (V 1.12) with SS3.
Just copy this 3 components from the ZF to /framework/thirdparty/Zend/
Mail (incl. Mail.php)
Mime (incl. Mime.php)
Validator (incl. Valitator.php) needed for SMTPor copy it to your dev dirs if you dont want t touch /framework/
-
Re: SS3 + swiftmailer problem, worked with SS2,4

1 November 2012 at 9:04am
Hi danzzz,
Thanks for your fix, but unfortuantly I didn't get it working. I am having lots of troubles at this moment with UserForms, since I cannont sent mails to emails of the domain, the website is hosted on. I used SMTPMailer in SilverStripe 2.4.*.
Is it possible that you can elaborate your last post a little more?
Or does this trick doesn't work for UserForms?
| 268 Views | ||
|
Page:
1
|
Go to Top |


