Email package

The Email package provides an interface for sending email using either php's mail function, sendmail or SMTP. The package supports:

Installation

The Email package is part of the official download (since version 1.1). You will have to enable the package either in the app config or include it on the fly.

'always_load' => array(
	'packages' => array(
		'email',
	),
),

// Or in a controller:

\Package::load('email');

Configuration

Create (or copy from the package) a config file at app/config/email.php. And change the settings needed.

Please note: The Email package loads the email config for you, so there is no need to autoload it.

General configuration

Param Type Default Description
defaults array
array( /* default config array */ )
Default settings for every setup group to use. In your setup group you overwrite these values.
default_setup string
'default'
The default setup to use if none is profided.
setups array
array(
		'default' => array(),
	)
A setups array with one default setup. Add your own or modify the default setup group.

Group configuration

Param Type Default Description
useragent string
'FuelPHP, PHP 5.3 Framework'
The user agent.
driver string
'mail'
The driver to use. Can be mail, smtp, sendmail, mailgun, mandrill or noop (only logs writes to log). Must be lowercase.
is_html boolean
false
Whether to send as html mail or as plain mail.
encode_headers boolean
true
Whether to encode subject and recipient names. Requires the mbstring extension.
charset string
'utf-8'
The email message charset.
encoding string
'8bit'
The email message encoding. Can be 7bit, 8bit, quoted-printable and base64.
priority string
\Email::P_NORMAL
The email's priority. Can be:
  • \Email::P_LOWEST
  • \Email::P_LOW
  • \Email::P_NORMAL
  • \Email::P_HIGH
  • \Email::P_HIGHEST
from.email string|false
false
Use this to set a default from email address.
from.name string|false
false
Use this to set a default from name.
validate bool
true
Set to false if you don't want to validate the addresses. Can result in failure in sending.
auto_attach bool
true
Whether to auto attach (background) images from a html body.
generate_alt bool
true
Whether to automatically generate an alt body from a html body.
wordwrap int|false
76
Word wrap size. If lower than anything above 0 will wrap. This setting is ignored when using base64 or quoted-printable.
sendmail_path string
'/usr/sbin/sendmail'
Path to sendmail.
smtp.host string
''
SMTP host.
smtp.port int
25
SMTP port.
smtp.username string
''
SMTP username.
smtp.password string
''
SMTP password.
smtp.timeout int
5
SMTP timeout. Increase this when a SMTP server times out during the sending proccess.
smtp.starttls bool
false
Whether a SMTP server needs STARTTLS command.
newline string
"\n"
New line.
attach_paths array
array('');
Array of attachment paths. When adding attachments, the driver will look in these paths and attach the first on found. Leave the empty ('') in there to allow absolute paths.
return_path string|false
false
Use this to set a default return-path email address.
remove_html_comments bool
true
When true, all comments inside the HTML body will be stripped.
relative_protocol_replacement string|false
false
When set to a string, all relative protocol URI's (those starting with // instead of http://) will be replaced by the value you specify here. This allows you to convert them to http:// or https://, since some Email clients (Outlook!) do not support relative protocol URI's.
mandrill.key string
'api_key'
Your Mandrill API Key.
mandrill.message_options array
array()
Check Mandrill docs. (Look for message struct)
mandrill.send_options.async bool
false
Enable a background sending mode
mandrill.send_options.ip_pool string
null
The name of the dedicated ip pool that should be used to send the message
mandrill.send_options.send_at string
null
When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format.

Make sure to install mandrill/mandrill composer package if you want to use the mandrill driver.

Mailgun configuration

Param Type Default Description
key string
'YOUR KEY'
The key of your mailgun account.
domain string
'YOUR DOMAIN'
The domain of your website