简体   繁体   中英

Symfony 1.4: email configuration

I'm trying to simply send an email from my server running Symfony 1.4 .

I have the usual basic mail server setup, with the server name mail.tixxit.com.au and port 25 . I have this configuration in my factories.xml :

  mailer:
    param:
      transport:
        class: Swift_SmtpTransport
          param:
            host:       mail.tixxit.com.au
            port:       25
            encryption: ssl # Not sure on this but have tried "tls" too
            username:   myaccount@tixxit.com.au
            password:   mypassword

Then I have a basic bit of send code in one of my actions:

        $this->getMailer()->composeAndSend(
            "myaccount@tixxit.com.au",
            "anotheraccount@gmail.com",
            "Message title",
            "Message content"
        );

From my what I've seen mentioned in other documentation, this should be all I need to do to send email from my server using Symfony in PHP, but this is not working. The send code does not give any errors, I can hit the mail.tixxit.com.au server from my web server fine, my credentials are definitely correct, and I have confirmed with support from my email hosting company that this should work and no configuration is required on their side to allow this.

But my mail isn't being sent. I have tried a whole lot of different settings in factories.xml but nothing works. It appears to send, but nothing ever arrives at anotheraccount@gmail.com . I have tried this on my local machine and my web server and get the same result.

What am I missing here? What Symfony/PHP/server/mail account settings do I need to actually make this work? Is there some fundamental other configuration that I am supposed to have set before the Symfony stuff that will allow me to send?

I couldn't find an answer to this. Nothing seemed to work. I gave up and used the natural Swift classes eg:

        $transport = Swift_SmtpTransport::newInstance('mail.tixxit.com.au', 25)
            ->setUsername('myaccount@tixxit.com.au')->setPassword('mypassword');

        $mailer = Swift_Mailer::newInstance($transport);

        $message = Swift_Message::newInstance("Message title")
            ->setFrom(array('myaccount@tixxit.com.au' => 'App'))
            ->setTo(array('anotheraccount@gmail.com'));

        $message->setBody("Message content.");

        if ($mailer->send($message, $errors)) {
            $success = true;
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM