-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d240857
commit 1955e07
Showing
1 changed file
with
10 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,10 @@ composer require effectra/mail | |
To send emails using the Effectra\Mail package, you need to create a mailer instance. The `MailerFactory` class provides a convenient way to create the mailer instance: | ||
|
||
```php | ||
use Effectra\Mail\Factory\MailerFactory; | ||
|
||
$mailerFactory = new MailerFactory(); | ||
use Effectra\Mail\Mailer; | ||
|
||
// Create a mailer instance | ||
$mailer = $mailerFactory->createMailer( | ||
$mailer = new Mailer( | ||
'smtp', // Mail driver (e.g., 'smtp', 'sendmail') | ||
'mail.example.com', // Mail server host | ||
587, // Mail server port | ||
|
@@ -44,19 +42,20 @@ $mailer = $mailerFactory->createMailer( | |
Once you have a mailer instance, you can use it to send emails. The `Mailer` class provides methods for setting the email recipients, subject, content, and more. Here's an example of sending an email: | ||
|
||
```php | ||
$mail = new Mail(); | ||
// Set email recipients | ||
$mailer->to('[email protected]'); | ||
$mailer->cc('[email protected]'); | ||
$mailer->bcc('[email protected]'); | ||
$mail->to('[email protected]'); | ||
$mail->cc('[email protected]'); | ||
$mail->bcc('[email protected]'); | ||
|
||
// Set email subject and content | ||
$mailer->subject('Hello, world!'); | ||
$mailer->text('This is the plain text content of the email.'); | ||
$mailer->html('<p>This is the HTML content of the email.</p>'); | ||
$mail->subject('Hello, world!'); | ||
$mail->text('This is the plain text content of the email.'); | ||
$mail->html('<p>This is the HTML content of the email.</p>'); | ||
|
||
// Send the email | ||
try { | ||
$mailer->send(); | ||
$mailer->send($mail); | ||
echo 'Email sent successfully!'; | ||
} catch (Exception $e) { | ||
echo 'An error occurred while sending the email: ' . $e->getMessage(); | ||
|