Welcome Guest, Not a member yet? Register   Sign In
Mail problem [SOLVED]

(This post was last modified: 03-15-2022, 02:08 AM by JustJohnQ.)

Hello all,

Below code works without problems:
PHP Code:
public function phpMail(){
$to      '[email protected]';
$subject 'the subject';
$message 'hello Codeigniter 2';
$headers 'From: [email protected]';


Using Codeigniter's built-in mail function:
PHP Code:
public function ciMail() {
$email = \Config\Services::email();
$email->setFrom('[email protected]''Name');
$email->setTo('[email protected]');
$email->setSubject('Email Test');
$email->setMessage('Testing the email class.');


I get an error:
"Unable to send email using PHP mail(). Your server might not be configured to send mail using this method."
$fromEmail and $fromName are set in App\Config\Email.php. $protocol is set to 'mail'.

Any help is aprreciated.


last time i read about using php mail() function i also read about various security concerns. I just use : https://github.com/PHPMailer/PHPMailer

The good thing about it , is that on developing a web on local host , PHPMailer works and so i can play about with it also developing spam detector code so , i don't get too much spam.

I have the PHPMailer directory at the same level as the app, public dirs etc and use autoload class so all the classes are found . Then in my controller that i use i have at the beginning

<?php namespace App\Controllers;

use CodeIgniter\Controller;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
use \App\Andy\CheckSpam;
use \App\Andy\Utility;
use CodeIgniter\I18n\Time;
I use Arch Linux by the way 

CMS in Action

Thanks for your suggestion. I will try it out soon. In the mean time I solved the particular problem with the CI mail fuction. The server on which the application is running doesn't accept the fith argument sending mail ('-f '). I temporarily changed the mail function until I can implement a better solution.

Theme © iAndrew 2016 - Forum software by © MyBB