Coder Social home page Coder Social logo

Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must be an instance of Swift_Mime_HeaderSet, none given about symfony HOT 9 CLOSED

umpirsky avatar umpirsky commented on May 21, 2024
Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must be an instance of Swift_Mime_HeaderSet, none given

from symfony.

Comments (9)

fabpot avatar fabpot commented on May 21, 2024

As stated in the documentation, you must first get the mailer, then create a message.

from symfony.

umpirsky avatar umpirsky commented on May 21, 2024

OK, thanks.

But why fatal error? And this strange messaage?

from symfony.

lsmith77 avatar lsmith77 commented on May 21, 2024

See also swiftmailer/swiftmailer#2

from symfony.

stof avatar stof commented on May 21, 2024

@umpersly This is because of the design of Swiftmailer. The initialization file has to be included before being able to use any classes of the library and SwiftmailerBundle includes it the first time you get the mailer service.

from symfony.

umpirsky avatar umpirsky commented on May 21, 2024

Thanks for the answers ;)

from symfony.

rochapablo avatar rochapablo commented on May 21, 2024

I don't get it!

$message = Swift_Message::newInstance(');
$message->setSubject('My subject');

Catchable fatal error: Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must be an instance of Swift_Mime_HeaderSet

How to fix?

from symfony.

alexandresalome avatar alexandresalome commented on May 21, 2024

@rochapablo You must first call $this->get('mailer') : It's a swiftmailer limitation.

from symfony.

stof avatar stof commented on May 21, 2024

@alexandresalome this limitation has been removed years ago thanks to the special autoloader registered by Swiftmailer (you should indeed avoid loading Swiftmailer classes with your own autoloader, but in composer-based projects, Swiftmailer handles it already)

from symfony.

rochapablo avatar rochapablo commented on May 21, 2024

I'm sorry, but I'm not understand yet, where came from the $this?

Because, where I'm calling the bellow code in my ClassController, and there's no get('mailer'). So it will not work.

$message = Swift_Message::newInstance();
$message->setSubject('My subject');

from symfony.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.