Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1086371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:48:17+00:00 2026-05-16T22:48:17+00:00

hi i am using swiftmailer component in my app and am looking for a

  • 0

hi i am using swiftmailer component in my app and am looking for a way to have a separate config (perhaps in config folder?) for swiftmailer that checks what debug mode i am using and thus uses different settings?

case 1: on production mode use simple smtp server without auth.
case 2: on debug mode use gmail settings or other settings since i am developing locally

is this possible?

the settings code case 1:

$this->SwiftMailer->smtpHost = ''; 

the settings code case 2:

        $this->SwiftMailer->smtpType = ''; 
        $this->SwiftMailer->smtpHost = ''; 
        $this->SwiftMailer->smtpPort =; 
        $this->SwiftMailer->smtpUsername = ''; 
        $this->SwiftMailer->smtpPassword = ''; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:48:18+00:00Added an answer on May 16, 2026 at 10:48 pm

    I think the quickest way would be:

    <?php
        Configure::load('swiftmailer');
        $this->SwiftMailer->smtpType =
          Configure::read('SwiftMailer.'.Configure::read().'.smtpType');
        $this->SwiftMailer->smtpHost = 
          Configure::read('SwiftMailer.'.Configure::read().'.smtpHost');
        $this->SwiftMailer->smtpPort = 
          Configure::read('SwiftMailer.'.Configure::read().'.smtpPort');
        $this->SwiftMailer->smtpUsername = 
          Configure::read('SwiftMailer.'.Configure::read().'.smtpUsername');
        $this->SwiftMailer->smtpPassword = 
          Configure::read('SwiftMailer.'.Configure::read().'.smtpPassword');
    ?>
    

    Now where to put it on.
    I would suggest the Controller constructor, that way it’s nice and tidy.
    For the values you can always use a private config file:

    // /app/config/swiftmailer.php:
    <?php
      $config['SwiftMailer'][0]['smtpType'] = 'value';
      $config['SwiftMailer'][0]['smtpHost'] = 'value';
      $config['SwiftMailer'][0]['smtpPort'] = 'value';
      $config['SwiftMailer'][0]['smtpUsername'] = 'value';
      $config['SwiftMailer'][0]['smtpPassword'] = 'value';
    
      $config['SwiftMailer'][1]['smtpType'] = 'value';
      $config['SwiftMailer'][1]['smtpHost'] = 'value';
      $config['SwiftMailer'][1]['smtpPort'] = 'value';
      $config['SwiftMailer'][1]['smtpUsername'] = 'value';
      $config['SwiftMailer'][1]['smtpPassword'] = 'value';
    
      $config['SwiftMailer'][2]['smtpType'] = 'value';
      $config['SwiftMailer'][2]['smtpHost'] = 'value';
      $config['SwiftMailer'][2]['smtpPort'] = 'value';
      $config['SwiftMailer'][2]['smtpUsername'] = 'value';
      $config['SwiftMailer'][2]['smtpPassword'] = 'value';
    ?>
    

    You can find a more generic example on Configuration Class v 1.2 and Configuration Class v 1.3.

    They seem to have the same content, so it seems that it hasn’t changed from 1.2 to 1.3.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that returns a PDF file using DOMPDF . It sends
Is there a way to read mails from pop3 recipit? I'm already using SwiftMailer
Using CRM 4, I have an entity form that contains a tab with an
Using online interfaces to a version control system is a nice way to have
I'm attempting to send an email using the CakePHP SwiftMailer component I found here:
I am using swiftmailer , a library for sending mail in php. The problem
I'd like to use Sendgrid WebAPI preferably without SMTP or Swiftmailer using the code
I am using Swift Mailer to check for bounced messages. I have created one
Using Nunit, I want to be able to write a test fixture that will
Using C# for ASP.NET and MOSS development, we often have to embed JavaScript into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.