Email has revolutionized communication.
Joomla! provides us with the JMail
class, which allows us to send email. JMail
supports three different mechanisms for sending email: the PHP mail function, Sendmail, and SMTP.
There is a global JMail
object that we can access using the JFactory
method getMailer()
. This object is configured with the global mail settings that administrators edit through the Global Configuration Server settings:
In order to send an email we must retrieve the JMail
object and set the sender's email address:
$mailer =& JFactory::getMailer(); $mailer->setSender('[email protected]');
There are two ways in which we can specify the email address. We can either use a string, as used in the previous line of code, or we can use an array that defines the email address and name:
$sender = array('[email protected]', 'example') $mailer =& JFactory::getMailer(); $mailer->setSender($sender);
We can also add reply-to addresses. Unlike setting the sender's address...