1084

php mailer, members module and round cube

Comments for “php mailer, members module and round cube”
 

Posted by Fin Motolinia on Saturday 29th June 2024 at 00:41 GMT

Hello, looking for some basic information about the difference between phpmailer which seems to be a php app similiar to round cube? Round cube comes default on my server. I am not excited about composer and whatever else that brings but after writing this will go over a certain thread by a Mr. Green on the subject. I thought that the trongate php mailer module was a mailer on its own but am now realizing it probably calls upon/works with another server side app, ie, phpmailer which I will have to install unless I can write my own mod for roundcube. Thank you in advance for any thought or guidance on whats right or wrong with my thinking or maybe what questions I should be asking
Level One Member

Fin Motolinia

User Level: Level One Member

Date Joined: 18/01/2024

Posted by DaFa on Saturday 29th June 2024 at 03:25 GMT

Hi Fin,

PHPMailer vs. Roundcube

PHPMailer:
• A PHP library that provides a way to send emails programmatically.
• It's not a full email client like Roundcube.
• It allows you to send emails using SMTP, which can be configured with various email services.

Roundcube:
• A web-based IMAP email client.
• It provides a user interface for managing and sending emails.
• It's not designed to be used programmatically within your PHP scripts.

The mailman module created by Dan is designed to work with the 'Simple Members' module using PHPMailer. Here’s how it fits together:
• Mailman Module: This module for Trongate facilitates email sending.
• PHPMailer: The mailman module uses PHPMailer to handle the actual process of sending emails in conjunction with the simple members module.

However, you can use PHPmailer directly in your apps very easily:
1. Install PHPMailer:
    • Using Composer: composer require phpmailer/phpmailer
    • Manually: Download from GitHub and include the files in your project.

Here is an example controller called 'Email.php', where I have installed PHPMailer in the assets folder of the 'email' module and configured PHPMailer to use Gmail:
<?php
require_once APPPATH . 'modules/email/assets/vendor/autoload.php';
// require_once '../vendor/autoload.php'; // change to this if you installed in the root of your app

use PHPMailer\PHPMailer\PHPMailer;

class Email extends Trongate {

    function index() {

        $mail = new PHPMailer(true);

        try {
            //Server settings
            $mail->isSMTP();
            $mail->Host = 'smtp.gmail.com';
            $mail->SMTPAuth = true;
            $mail->Username = '[email protected]';
            $mail->Password = 'your_password';
            $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
            $mail->Port = 587;

            //Recipients
            $mail->setFrom('[email protected]', 'Your Name');
            $mail->addAddress('[email protected]', 'their email address');
            // $mail->addReplyTo('[email protected]', 'their name to reply');
            // $mail->addCC('[email protected]');
            // $mail->addBCC('[email protected]');

            // Attachments
            // $mail->addAttachment(APPPATH . 'modules/email/assets/img/01.jpg');

            //Content
            $mail->isHTML(true);
            $mail->Subject = 'Test Subject';
            $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
            $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

            $mail->send();
            echo 'Email has been sent';
        } catch (Exception $e) {
            echo "Email could not be sent. Mailer Error: {$mail->ErrorInfo}";
        }
    }
}
If you are using Gmail with 2-factor auth turned on - you will need to create an app password as your normal password will not work.

Happy coding!

ps. If you could read your last post, I left you a message >> https://trongate.io/help_bar_threads/display/n6jeP3dNC5vZQdru

This comment was edited by DaFa on Saturday 29th June 2024 at 06:32 GMT

Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by Fin Motolinia on Sunday 30th June 2024 at 21:51 GMT

Hello, thank you for the description of php mailer vs roundcube , definitely cleared up my thinking, and I have listened to some other demos and messed with composer and php mailer just a little bit at this point now, but one more clarification and I think you state this in the mailman video. Mailman is actually a slimmed down version of php mailer so if all one needs is new user/ forgot password functionality, than mailman alone should do it and has the appropriate packages it needs already. I do not have to use composer at all if this is correct. On first look directorys look similiar, except composer apparently normally uses a "vendor" directory

This comment was edited by Fin Motolinia on Sunday 30th June 2024 at 22:02 GMT

Level One Member

Fin Motolinia

User Level: Level One Member

Date Joined: 18/01/2024

×