@@ -265,76 +265,12 @@ the [Stackdriver Error Reporting UI][stackdriver-errorreporting-ui]! If you copi
265265` https://YOUR_PROJECT_ID.appspot.com/en/logging/notice` and
266266` https://YOUR_PROJECT_ID.appspot.com/en/logging/exception`
267267
268- # # Send emails
269-
270- As stated in the [Migration guide from PHP 5.x to 7.x][cloud-migration] the Mail API or App Engine has been removed.
271- The recommended way to send emails is to use a third-party mail provider such as [Sendgrid][sendgrid], [Mailgun][mailgun] or [Mailjet][mailjet].
272- Hosting your application on GAE, most of these providers will offer you up to 30,000 emails per month and you will be charged only if you send more.
273- You will have the possibility to track your email delivery and benefit from all the feature of a real email broadcasting system.
274-
275- # ## Install
276-
277- First you need to install the mailer component :
278-
279- ` ` `
280- composer require symfony/mailer
281- ` ` `
282-
283- Then depending on the provider you chose, you need to add the additional component, [Symfony mailer documentation][symfony-mailer]
284- will give you all the specific per provider but here is an example with Mailgun :
285-
286- ` ` `
287- composer require symfony/mailgun-mailer
288- ` ` `
289-
290- This recipe will automatically add the following ENV variable to your .env file :
291-
292- ` ` `
293- # Will be provided by mailgun once your account will be created
294- MAILGUN_KEY= xxxxxx
295- # Should be your Mailgun MX record
296- MAILGUN_DOMAIN= mg.yourdomain.com
297- # Region is mandatory if you chose server outside the US otherwise your domain will not be found
298- MAILER_DSN=mailgun://$MAILGUN_KEY:$MAILGUN_DOMAIN@default?region=eu
299- ` ` `
300-
301- From that point, you just need to create your account and first domain adding all the DNS Records.
302- [Mailgun documentation][mailgun-add-domain] will lead you through these steps.
303-
304- You can now send emails in Controller and Service as usual :
305- ` ` `
306- // src/Controller/MailerController.php
307- namespace App\C ontroller;
308-
309- use Symfony\B undle\F rameworkBundle\C ontroller\A bstractController;
310- use Symfony\C omponent\M ailer\M ailerInterface;
311- use Symfony\C omponent\M ime\E mail;
312-
313- class MailerController extends AbstractController
314- {
315- /**
316- * @Route("/email")
317- */
318- public function sendEmail(MailerInterface $mailer)
319- {
320- $email = (new Email())
321- 322- 323- ->subject('Time for Symfony Mailer!')
324- ->text('Sending emails is fun again!');
325-
326- $mailer->send($email);
327- }
328- }
329- ` ` `
330-
331268[cloud-sdk] : https://cloud.google.com/sdk/
332269[cloud-build] : https://cloud.google.com/cloud-build/
333270[cloud-sql] : https://cloud.google.com/sql/docs/
334271[cloud-sql-create] : https://cloud.google.com/sql/docs/mysql/create-instance
335272[cloud-sql-install] : https://cloud.google.com/sql/docs/mysql/connect-external-app#install
336- [cloud-sql-apis] : https://console.cloud.google.com/apis/library/sqladmin.googleapis.com/?pro
337- [cloud-migration] : https://cloud.google.com/appengine/docs/standard/php7/php-differences?hl=en#migrating_from_the_app_engine_php_sdk
273+ [cloud-sql-apis]:https://console.cloud.google.com/apis/library/sqladmin.googleapis.com/?pro
338274[create-project] : https://cloud.google.com/resource-manager/docs/creating-managing-projects
339275[enable-billing] : https://support.google.com/cloud/answer/6293499?hl=en
340276[symfony] : http://symfony.com
@@ -344,10 +280,5 @@ class MailerController extends AbstractController
344280[symfony-secret] : http://symfony.com/doc/current/reference/configuration/framework.html#secret
345281[symfony-env] : https://symfony.com/doc/current/configuration/environments.html#executing-an-application-in-different-environments
346282[symfony-override-cache] : https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-cache-directory
347- [symfony-mailer] : https://symfony.com/doc/current/mailer.html
348283[stackdriver-logging-ui] : https://console.cloud.google.com/logs
349284[stackdriver-errorreporting-ui] : https://console.cloud.google.com/errors
350- [sendgrid] : https://sendgrid.com/
351- [mailgun] : https://www.mailgun.com/
352- [mailjet] : https://www.mailjet.com/
353- [mailgun-add-domain] : https://help.mailgun.com/hc/en-us/articles/203637190-How-Do-I-Add-or-Delete-a-Domain-
0 commit comments