I am working on a CodeIgniter application and trying to send emails with different from addresses for different purposes:
Below is one of the controller codes for email sending:
$email = ConfigServices::email();
$email->setFrom('[email protected]');
$email->setTo('[email protected]');
$email->setSubject('Test subject');
$email->setMessage('Test msg body');
$email->send();
Here I want to use the mail address: [email protected] as the from(sender) address.
However, when I use the above-mentioned code, the email sending fails(seems not sending).
If I change the from address to [email protected], it works perfectly.
My app/Config/Email.php is as follows:
public string $protocol = 'smtp';
public string $mailPath = '/usr/sbin/sendmail';
public string $SMTPHost = 'smtp.hostinger.com';
public string $SMTPUser = '[email protected]';
public string $SMTPPass = 'XXXXXXXX';
public int $SMTPPort = 465;
Can anyone please guide me on what is wrong with my script? Or does Codeigniter support this setting for the from address?