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 8397651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:50:48+00:00 2026-06-09T20:50:48+00:00

I am creating a mail class in symfony using swiftmailer. I have written mailer

  • 0

I am creating a mail class in symfony using swiftmailer. I have written mailer class as follow:

<?php
namespace Ens\NewBundle\Controller\Services;

class MyMailers
{

 public $setTovar='';


 public function setToloc($name)
 {
    $this->setTovar=$name;
 }

 public function mail()
 {
        date_default_timezone_set('Asia/Kolkata');

        $transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
        ->setUsername('smtptest.hi@gmail.com')
        ->setPassword('scientech');
        $mailer = \Swift_Mailer::newInstance($transport);
        $message = \Swift_Message::newInstance('Wonderful Subject');
        $message->setFrom('ucerturohit@gmai.com');
        $message->setTo($this->setTovar);
        $message->setBody('Here is the message itself');
        $numSent = $mailer->send($message);
        return $numSent;
    }
}

and in Notification.php I have written code as follow:

//require_once('MyMailers.php');
use Ens\NewBundle\contrller\Services\MyMailers;
    function NotificationOnSignUp($z)
    {
    // echo $z;die;
         // $y=unserialize($z);
      echo $z;
      echo "<pre>";
      print_r($z);
      echo "</pre>";
          $x=new MyMailers;
      $x->setToloc($z['to']);

          $z=$x->mail();
      if($z==1)
   $name='success';
  else
   $name='failed';

when I am running this code then I am getting the error :

Fatal error: Class 'Ens\NewBundle\contrller\Services\MyMailers' not found in /var/www/Symfony/src/Ens/NewBundle/Controller/Services/Notification.php on line 13 what should I do ??

  • 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-06-09T20:50:51+00:00Added an answer on June 9, 2026 at 8:50 pm

    $x=new \MyMailers; will find in the global namespace.

    What you should do is:

    use Ens\NewBundle\Controller\Services\MyMailers as MyMailers;
    
    $x = new MyMailers;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a class that will handle mails and I am using PHP.
When creating a new message using Mail on the iPhone, and after typing the
How can I send an email in one line without creating a mailer class?
I have one class user that is initiated in /update/user.php when update.php is started.
Thanks in advance. I have to send mail using spring. When i tried the
I am creating a mail session inside of my servlet context and then using
I have generated html like this: <div class=row> <div class=item google></div> <div class=item mail></div>
I'm creating mail sender web service. Every 10 second 1 mail sent. My total
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating a JApplet I have 2 Text Fields, a button and a Text Area.

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.