Almas Adilbek
Almas Adilbek

Reputation: 4410

Symfony framework: How do I send email from localhost?

Using symfony framework how can I send test emails from localhost?
What are most easiest ways?
Thank you!

Upvotes: 2

Views: 4332

Answers (2)

cvaldemar
cvaldemar

Reputation: 6993

The easiest way, I suppose and what I normally do, is to configure the _dev environment to use good old Gmail (or any other provider for that matter). Set this up in your apps/frontend/config/factories.yml:

dev:
  mailer:
    class: sfMailer
    param:
      logging:           %SF_LOGGING_ENABLED%
      charset:           %SF_CHARSET%
      delivery_strategy: realtime
      transport:
        class: Swift_MailTransport
        param:
          host:       smtp.gmail.com
          port:       465
          encryption: ssl
          username:   [email protected]
          password:   your-password

Sending e-mails will ofcourse take a little longer because PHP would have to connect to Google's servers and deliver the message.

This way you can worry about setting up a proper SMTP on your production server, and just let your dev machine be for development. Another advantage is if your develop on the road, and your local cafe / airport / kiosk blocks port 25 (they usually do) you won't have problems delivering mail.

Upvotes: 4

Frank
Frank

Reputation: 360

You could install a mail server such as Postfix, and configure it to use an external mail server as an SMTP relay. Otherwise, most email services will either refuse to accept your message, or categorize it as spam.

This thread at serverfault might be helpful to you-it explains how to configure postfix to relay emails through gmail: Configure Postfix to send/relay emails Gmail (smtp.gmail.com) via port 587

Upvotes: 2

Related Questions