Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite96e12d

Browse files
committed
feature#3234 [Cookbook] New cookbok: How to use the Cloud to send Emails (bicpi)
This PR was submitted for the 2.2 branch but it was merged into the 2.3 branch instead (closes#3234).Discussion----------[Cookbook] New cookbok: How to use the Cloud to send Emails| Q | A| ------------- | ---| Doc fix? | no| New docs? | yes| Applies to | all| Fixed tickets | -This is a new cookbook article as proposed in#3193, I hope you like it.Please let me know if there's something I can improve, especially regarding my English ;-)Commits-------6bbbc8a Fix wording and formatting4f7c0f3 Fixes and improvements after review3490722 [Cookbook] New cookbok: How to use the Cloud to send Emails
2 parents1714a31 +0f6c246 commite96e12d

File tree

4 files changed

+137
-13
lines changed

4 files changed

+137
-13
lines changed

‎cookbook/email/cloud.rst

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
..index::
2+
single: Emails; Using the cloud
3+
4+
How to use the Cloud to Send Emails
5+
===================================
6+
7+
Requirements for sending emails from a production system differ from your
8+
development setup as you don't want to be limited in the number of emails,
9+
the sending rate or the sender address. Thus,
10+
:doc:`using Gmail</cookbook/email/gmail>`_ or similar services is not an
11+
option. If setting up and maintaining your own reliable mail server causes
12+
you a headache there's a simple solution: Leverage the cloud to send your
13+
emails.
14+
15+
This cookbook shows how easy it is to integrate
16+
`Amazon's Simple Email Service (SES)`_ into Symfony.
17+
18+
.. note::
19+
20+
You can use the same technique for other mail services, as most of the
21+
time there is nothing more to it than configuring an SMTP endpoint for
22+
Swift Mailer.
23+
24+
In the Symfony configuration, change the Swift Mailer settings ``transport``,
25+
``host``, ``port`` and ``encryption`` according to the information provided in
26+
the `SES console`_. Create your individual SMTP credentials in the SES console
27+
and complete the configuration with the provided ``username`` and ``password``:
28+
29+
..configuration-block::
30+
31+
..code-block::yaml
32+
33+
# app/config/config.yml
34+
swiftmailer:
35+
transport:smtp
36+
host:email-smtp.us-east-1.amazonaws.com
37+
port:465# different ports are available, see SES console
38+
encryption:tls# TLS encryption is required
39+
username:AWS_ACCESS_KEY# to be created in the SES console
40+
password:AWS_SECRET_KEY# to be created in the SES console
41+
42+
..code-block::xml
43+
44+
<!-- app/config/config.xml-->
45+
<?xml version="1.0" encoding="UTF-8" ?>
46+
<containerxmlns="http://symfony.com/schema/dic/services"
47+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48+
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
49+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
50+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
51+
52+
<!-- ...-->
53+
<swiftmailer:config
54+
transport="smtp"
55+
host="email-smtp.us-east-1.amazonaws.com"
56+
port="465"
57+
encryption="tls"
58+
username="AWS_ACCESS_KEY"
59+
password="AWS_SECRET_KEY"
60+
/>
61+
</container>
62+
63+
..code-block::php
64+
65+
// app/config/config.php
66+
$container->loadFromExtension('swiftmailer', array(
67+
'transport' => 'smtp',
68+
'host' => 'email-smtp.us-east-1.amazonaws.com',
69+
'port' => 465,
70+
'encryption' => 'tls',
71+
'username' => 'AWS_ACCESS_KEY',
72+
'password' => 'AWS_SECRET_KEY',
73+
));
74+
75+
The ``port`` and ``encryption`` keys are not present in the Symfony Standard
76+
Edition configuration by default, but you can simply add them as needed.
77+
78+
And that's it, you're ready to start sending emails through the cloud!
79+
80+
..tip::
81+
82+
If you are using the Symfony Standard Edition, configure the parameters in
83+
``parameters.yml`` and use them in your configuration files. This allows
84+
for different Swift Mailer configurations for each installation of your
85+
application. For instance, use Gmail during development and the cloud in
86+
production.
87+
88+
..code-block::yaml
89+
90+
# app/config/parameters.yml
91+
parameters:
92+
# ...
93+
mailer_transport:smtp
94+
mailer_host:email-smtp.us-east-1.amazonaws.com
95+
mailer_port:465# different ports are available, see SES console
96+
mailer_encryption:tls# TLS encryption is required
97+
mailer_user:AWS_ACCESS_KEY# to be created in the SES console
98+
mailer_password:AWS_SECRET_KEY# to be created in the SES console
99+
100+
..note::
101+
102+
If you intend to use Amazon SES, please note the following:
103+
104+
* You have to sign up to `Amazon Web Services (AWS)`_;
105+
106+
* Every sender address used in the ``From`` or ``Return-Path`` (bounce
107+
address) header needs to be confirmed by the owner. You can also
108+
confirm an entire domain;
109+
110+
* Initially you are in a restricted sandbox mode. You need to request
111+
production access before being allowed to send to arbitrary
112+
recipients;
113+
114+
* SES may be subject to a charge.
115+
116+
.. _`Amazon's Simple Email Service (SES)`:http://aws.amazon.com/ses
117+
.. _`SES console`:https://console.aws.amazon.com/ses
118+
.. _`Amazon Web Services (AWS)`:http://aws.amazon.com

‎cookbook/email/gmail.rst

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
..index::
22
single: Emails; Gmail
33

4-
How to use Gmail tosend Emails
4+
How to use Gmail toSend Emails
55
===============================
66

77
During development, instead of using a regular SMTP server to send emails, you
@@ -29,31 +29,35 @@ In the development configuration file, change the ``transport`` setting to
2929
..code-block::xml
3030
3131
<!-- app/config/config_dev.xml-->
32-
33-
<!--
32+
<?xml version="1.0" encoding="UTF-8" ?>
33+
<containerxmlns="http://symfony.com/schema/dic/services"
34+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3435
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
35-
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
36-
-->
36+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
37+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">
3738
38-
<swiftmailer:config
39-
transport="gmail"
40-
username="your_gmail_username"
41-
password="your_gmail_password" />
39+
<!-- ...-->
40+
<swiftmailer:config
41+
transport="gmail"
42+
username="your_gmail_username"
43+
password="your_gmail_password"
44+
/>
45+
</container>
4246
4347
..code-block::php
4448
4549
// app/config/config_dev.php
4650
$container->loadFromExtension('swiftmailer', array(
47-
'transport' =>"gmail",
48-
'username' =>"your_gmail_username",
49-
'password' =>"your_gmail_password",
51+
'transport' =>'gmail',
52+
'username' =>'your_gmail_username',
53+
'password' =>'your_gmail_password',
5054
));
5155
5256
You're done!
5357

5458
..tip::
5559

56-
If you are using the Symfony Standard Edition, configure the parametersat ``parameters.yml``:
60+
If you are using the Symfony Standard Edition, configure the parametersin ``parameters.yml``:
5761

5862
..code-block::yaml
5963

‎cookbook/email/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Email
66

77
email
88
gmail
9+
cloud
910
dev_environment
1011
spool
1112
testing

‎cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
* :doc:`/cookbook/email/email`
7070
* :doc:`/cookbook/email/gmail`
71+
* :doc:`/cookbook/email/cloud`
7172
* :doc:`/cookbook/email/dev_environment`
7273
* :doc:`/cookbook/email/spool`
7374
* :doc:`/cookbook/email/testing`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp