0

In my project I have multiple modules as:

1. Become sponsor
2. Become exhibitor
3. Call for papers
4. Etc

In these modules I have a form for users to fill and submit data. It's like a registration form. If registration is succeeded, I send "welcome message" to user's email. This email template is common for all situations!

So, I need a common function, method to call in order to send that email. I don't want to write it in each action. So that, in that method I could get instance of mailer, user culture etc, like in a basic module action.

Please help, brothers!

1 Answer 1

5

You can create a new class in your lib directory.

The file will automatically included in your action files.

Then in your action:

$obj = new YourNewClass();
$obj->sendMail($p1, $p2, ...);
Sign up to request clarification or add additional context in comments.

2 Comments

How can I include it in other modules? Can you give simple example of that class?
By default, classes stored in the following directories in your projects benefit from the autoloading automatically: myproject/lib/ myproject/lib/model myproject/apps/myapp/lib/ myproject/apps/myapp/modules/mymodule/lib Then your class should send the mail based on some params. But this is another subject?!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.