From 90bf62a2c92681dae8caa994ba93e212454c6356 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 29 Nov 2023 12:01:05 +0100 Subject: [PATCH] readme: added jumbo, updated --- readme.md | 58 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/readme.md b/readme.md index 045c35e..e1f11f5 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,4 @@ -Nette Mail: Sending E-mails -=========================== +[![Nette Mail](https://github.com/nette/mail/assets/194960/8b2371bd-0976-443c-b60a-460eb8b3222f)](https://doc.nette.org/en/mail) [![Downloads this Month](https://img.shields.io/packagist/dm/nette/mail.svg)](https://packagist.org/packages/nette/mail) [![Tests](https://github.com/nette/mail/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/mail/actions) @@ -7,13 +6,17 @@ Nette Mail: Sending E-mails [![Latest Stable Version](https://poser.pugx.org/nette/mail/v/stable)](https://github.com/nette/mail/releases) [![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/mail/blob/master/license.md) +  + Introduction ------------ Are you going to send emails such as newsletters or order confirmations? Nette Framework provides the necessary tools with a very nice API. -Documentation can be found on the [website](https://doc.nette.org/mailing). +Documentation can be found on the [website](https://doc.nette.org/en/mail). + +  [Support Me](https://github.com/sponsors/dg) @@ -25,6 +28,8 @@ Do you like Nette Mail? Are you looking forward to the new features? Thank you! +  + Installation ------------ @@ -35,6 +40,8 @@ composer require nette/mail It requires PHP version 8.0 and supports PHP up to 8.3. +  + Creating Emails =============== @@ -74,7 +81,7 @@ Images can also be extremely easily inserted into the HTML body of an email. Jus // automatically adds /path/to/images/background.gif to the email $mail->setHtmlBody( 'Hello ', - '/path/to/images' + '/path/to/images', ); ``` @@ -118,14 +125,14 @@ $mail = new Nette\Mail\Message; $mail->setFrom('John ') ->addTo('jack@example.com') ->setHtmlBody( - $latte->renderToString('email.latte', $params), - '/path/to/images' + $latte->renderToString('/path/to/email.latte', $params), + '/path/to/images', ); ``` File `email.latte`: -```html +```latte @@ -146,6 +153,7 @@ File `email.latte`: Nette automatically inserts all images, sets the subject according to the `` element, and generates text alternative for HTML body. + <!----> Sending Emails @@ -174,22 +182,22 @@ SmtpMailer To send mail via the SMTP server, use `SmtpMailer`. ```php -$mailer = new Nette\Mail\SmtpMailer([ - 'host' => 'smtp.gmail.com', - 'username' => 'franta@gmail.com', - 'password' => '*****', - 'secure' => 'ssl', -]); +$mailer = new Nette\Mail\SmtpMailer( + host: 'smtp.gmail.com', + username: 'franta@gmail.com', + password: '*****', + encryption: Nette\Mail\SmtpMailer::EncryptionSSL, +); $mailer->send($mail); ``` -If you do not specify `host`, the value from php.ini will be used. The following additional keys can be used in the options: +The following additional parameters can be passed to the constructor: * `port` - if not set, the default 25 or 465 for `ssl` will be used -* `context` - allows you to set [SSL context options](https://www.php.net/manual/en/context.ssl.php) for connection * `timeout` - timeout for SMTP connection * `persistent` - use persistent connection * `clientHost` - client designation +* `streamOptions` - allows you to set [SSL context options](https://www.php.net/manual/en/context.ssl.php) for connection FallbackMailer @@ -201,13 +209,15 @@ It does not send email but sends them through a set of mailers. If one mailer fa $mailer = new Nette\Mail\FallbackMailer([ $smtpMailer, $backupSmtpMailer, - $sendmailMailer + $sendmailMailer, ]); $mailer->send($mail); ``` -Other parameters in the constructor include the number of repeat and waiting time in miliseconds. +Other parameters in the constructor include the number of repeat and waiting time in milliseconds. + + <!----> DKIM ==== @@ -216,14 +226,14 @@ DKIM (DomainKeys Identified Mail) is a trustworthy email technology that also he The recipient's server compares this signature with the public key stored in the domain's DNS records. By matching the signature, it is shown that the email actually originated from the sender's domain and that the message was not modified during the transmission of the message. ```php -$options = [ - 'domain' => 'nette.org', - 'selector' => 'dkim', - 'privateKey' => file_get_contents('../dkim/dkim.key'), - 'passPhrase' => '****', -]; +$signer = new Nette\Mail\DkimSigner( + domain: 'nette.org', + selector: 'dkim', + privateKey: file_get_contents('../dkim/dkim.key'), + passPhrase: '****', +); $mailer = new Nette\Mail\SendmailMailer; // or SmtpMailer -$mailer->setSigner(new Nette\Mail\DkimSigner($options)); +$mailer->setSigner($signer); $mailer->send($mail); ```