• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
email example for CI4

#1
Hi All, I am Tom and I am a newbie to any framework but I love to learning Codeigniter.
I followed the tutorial below but not work, I had tried gmail and and other mail server

https://www.tutsmake.com/send-email-in-c...with-smtp/
Is there any mail example or PHPMailer example for CI4
many thanks and hope you everything is well

I am trying to make PHPMailer as a helper
PHP Code:
<?php 
use PHPMailer\PHPMailer\PHPMailer
use 
PHPMailer\PHPMailer\Exception

function 
send_mail($send_from NULL$send_to NULL$send_name NULL$send_subj NULL$send_body NULL){
require 
APPPATH.'ThirdParty/PHPMailer/Exception.php';
require 
APPPATH.'ThirdParty/PHPMailer/PHPMailer.php';
require 
APPPATH.'ThirdParty/PHPMailer/SMTP.php';


    $mail = new PHPMailer(true);                              // Passing `true` enables exceptions 
    try {
        //Server settings
        $mail->SMTPDebug SMTP::DEBUG_SERVER;                      // Enable verbose debug output
        $mail->isSMTP();                                            // Send using SMTP
        $mail->Host       'smtp1.example.com';                    // Set the SMTP server to send through
        $mail->SMTPAuth   true;                                   // Enable SMTP authentication
        $mail->Username   '[email protected]';                     // SMTP username
        $mail->Password   'secret';                               // SMTP password
        $mail->SMTPSecure PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
        $mail->Port       587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

        //Recipients
        $mail->setFrom($send_from'Mailer');
        $mail->addAddress($send_to$send_name);     // Add a recipient
        #$mail->addAddress('[email protected]');               // Name is optional
        #$mail->addReplyTo('[email protected]', 'Information');
        #$mail->addCC('[email protected]');
        #$mail->addBCC('[email protected]');

        // Attachments
        #$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
        #$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

        // Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject $send_subj;
        $mail->Body    $send_body;
        #$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

        $mail->send();
        echo 'Message has been sent';
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }


Reply


Messages In This Thread
email example for CI4 - by carlkyo - 06-24-2020, 05:25 AM
RE: email example for CI4 - by Chroma - 06-29-2020, 09:04 AM
RE: email example for CI4 - by ivantcholakov - 06-29-2020, 02:04 PM
RE: email example for CI4 - by carlkyo - 07-02-2020, 02:48 AM
RE: email example for CI4 - by mlurie - 07-17-2020, 06:46 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.