1

I am trying to get this mail sent on registration using SwiftMailer, however it keeps throwing this error.

I am using this add-on for osCommerce: http://addons.oscommerce.com/info/901

I have followed the exact instructions as per what he said. Also added permissions still the same thing.

I am posting the code below:

CODE:

      if (EMAIL_TRANSPORT == 'smtp') {
    include_once(DIR_FS_CATALOG.DIR_WS_CLASSES . 'SwiftEmailer/swift_required.php');

    $body             = $this->html;
    $body             = preg_replace("[]",'',$body);

    $host_name = explode('://',EMAIL_SMTP_HOST_SERVER);
    if(count($host_name)>1){
        $transport        = Swift_SmtpTransport::newInstance($host_name[1], EMAIL_SMTP_PORT_SERVER, $host_name[0])
            ->setUsername(EMAIL_SMTP_USERNAME)
            ->setPassword(EMAIL_SMTP_PASSWORD);
    } else {
        $transport        = Swift_SmtpTransport::newInstance(EMAIL_SMTP_HOST_SERVER, EMAIL_SMTP_PORT_SERVER)
            ->setUsername(EMAIL_SMTP_USERNAME)
            ->setPassword(EMAIL_SMTP_PASSWORD);
    }


    $mailer           = Swift_Mailer::newInstance($transport);
    $message          = Swift_Message::newInstance($subject)
      ->setFrom(array($from_addr => $from_name))
      ->setTo(array($to_addr => $to_name))
      ->setMaxLineLength(50);


    if($body){
        $message->setBody($body, 'text/html', CHARSET);
    }
    if($this->text){
        $message->setBody($this->text, 'text/plain', CHARSET);
    }
    else{
        $message->setBody($this->html_text, 'text/html', CHARSET);
    }

    $mailer->send($message);
  }

If anyone could help me sort out this issue that would be great. Thank you

DEV
  • 647
  • 4
  • 19
  • 31
  • Can you change the `include_once` to `require_once` to make sure at least the initial file is loading? If so, it may be an issue with how the class is being autoloaded. You could look at the docs for both [Swift](http://swiftmailer.org/docs/including-the-files.html) and [OSCommerce](https://library.oscommerce.com/Online&en&oscom_2_4&developers&framework). – ldg Jul 09 '16 at 07:42
  • Hi, thanks for the reply. I will have a look at it. – DEV Jul 09 '16 at 07:45
  • Ok I don't get an error anymore but I am getting a blank page. it isn't redirecting to the success page not is a mail getting sent. – DEV Jul 09 '16 at 07:56
  • do you have all error reporting turned on? – ldg Jul 09 '16 at 09:02
  • Yes, I did get the message initially. And I did not change anything else. – DEV Jul 09 '16 at 09:22

0 Answers0