proprietes-privees / eb-emailbundle
此包的最新版本(1.0.0)没有可用的许可证信息。
非常简单的邮件发送器
1.0.0
2016-03-14 12:28 UTC
Requires
- php: >=5.4
- symfony/swiftmailer-bundle: ~2.3
This package is not auto-updated.
Last update: 2024-09-20 02:24:46 UTC
README
最小配置
只需添加您的发送者(实际上只需要一个)
eb_email:
senders:
-
name: John DOE
email: john.doe@gmail.com
emails: []
配置您的邮件
我们需要发送一封带有特定主题和正文的 contact 邮件。
eb_email:
# ...
emails:
contact:
subject: 'New contact !'
text_template: 'AppBundle:Email:_contact.txt.twig'
如果您想发送包含 text/plain 和 text/html 的替代邮件,请使用 html_template 键
eb_email:
# ...
emails:
contact:
subject: 'New contact !'
text_template: 'AppBundle:Email:_contact.txt.twig'
html_template: 'AppBundle:Email:_contact.html.twig'
您可以在主题中使用 twig 语法
eb_email:
# ...
emails:
contact:
subject: 'New contact from {{contact.name}} !'
# ...
发送您的邮件
$this->get('eb_email')->send('contact', 'john.doe@gmail.com');
带有 2 个收件人
$this->get('eb_email')->send('contact', [
'john.doe1@gmail.com',
'john.doe2@gmail.com',
]);
带有实现 getUsername 方法的用户对象
$this->get('eb_email')->send('contact', $user);
带有模板化的 message 变量
$this->get('eb_email')->send('contact', 'john.doe1@gmail.com', [
'message' => $message,
]);
带有 header 图像 <img src="{{ header }}"/>
$this->get('eb_email')->send('contact', 'john.doe1@gmail.com', [
'message' => $message,
], [
'header' => '/var/header.png',
]);
带有 PDF 附件
$this->get('eb_email')->send('contact', 'john.doe1@gmail.com', [
'message' => $message,
], [], [
'/var/attachment.pdf',
]);
配置所有邮件的全局设置、图像、附件和收件人
将 app_name 全局变量添加到所有邮件中
eb_email:
# ...
globals:
app_name: BundleDemo
将 header 和 footer 图像添加到所有邮件中(对于 twig 布局很有用)
eb_email:
# ...
images:
header: /var/header.png
footer: /var/footer.png
将一些 PDF 添加到所有邮件中
eb_email:
# ...
attachments:
- /var/terms.pdf
将收件人添加到所有邮件中
eb_email:
# ...
recipients:
-
name: AppName
email: contact@appname.com
配置一封邮件的图像和附件
将 map 图像添加到 contact 邮件中
eb_email:
# ...
emails:
contact:
# ...
images:
map: /var/map.png
将一个 PDF 添加到 contact 邮件中
eb_email:
# ...
emails:
contact:
# ...
attachments:
- /var/satisfaction.pdf
将一个默认收件人添加到 contact 邮件中
eb_email:
# ...
emails:
contact:
# ...
recipients:
-
name: AppName
email: contact@appname.com
完整配置
# Default configuration for "EBEmailBundle"
eb_email:
senders: # Required
# Sender name
name: ~ # Required, Example: John Doe
# Sender email
email: ~ # Required, Example: john.doe@gmail.com
# Global to add in each template
globals: # Example: A parameter
# Prototype
name: ~
# Images to attach inline
images: # Example: /path/to/file
# Prototype
name: ~
# Files to attach
attachments: [] # Example: /path/to/file
recipients:
# Recipient name
name: ~ # Required, Example: John Doe
# Recipient email
email: ~ # Required, Example: john.doe@gmail.com
emails:
# Prototype
name:
# Text Template
text_template: ~ # Required, Example: AcmeDefautBundle::_text_email.html.twig
# HTML Template
html_template: null # Example: AcmeDefautBundle::_html_email.html.twig
# Email subject
subject: ~ # Required, Example: Welcome {{user.username}} to {{app_name}} !
# Global to add in this template
globals: # Example: A parameter
# Prototype
name: ~
# Images to attach inline
images: # Example: /path/to/file
# Prototype
name: ~
# Files to attach
attachments: [] # Example: /path/to/file
recipients:
# Recipient name
name: ~ # Required, Example: John Doe
# Recipient email
email: ~ # Required, Example: john.doe@gmail.com