22
votes
Accepted
How to send email from Craft 3 custom plugin?
Edit: After the migration to Craft 3.1.x you should rather use this Code
/**
* @param string $html
* @param string $subject
* @param array|...
14
votes
Accepted
How do I set up Craft to send emails from my local MAMP/Virtual Host X dev environment
These days I just use Mandrill.
It's simple to set up, free unless you're sending tens of thousands of emails, and you can continue to use it on any development (or production) machine without any ...
14
votes
Accepted
Pass content of system messages to HTML Email Template
EmailService->sendEmailByKey() sets the htmlBody property of EmailModel to this:
$emailModel->htmlBody = "{% extends '{$template}' %}\n".
"{% set body %}\n".
$emailModel->htmlBody.
...
13
votes
Accepted
How do I get the Settings System email Address?
You can get this in a template like so:
{# returns an array of your email settings #}
{% set settings = craft.systemSettings.email %}
{# returns the email address #}
{{ settings.emailAddress }}
And ...
10
votes
Accepted
Passing Entry to craft()->templates->render()
You can just pass in the EntryModel straight to the view.
$html = craft()->templates->render('path/to/template', [ 'entry' => $entryModel ]);
9
votes
Accepted
How to set CC or BCC emails to EmailModel?
The way you do it now only adds email addresses as an array. You'll have to specify both email and name keys too, so it becomes like this:
$email->cc = array(
array('email' => 'email@email....
9
votes
Is there a way to detect if a action is triggered from a control panel form?
If anyone comes here looking for this answer for Craft 3 the function you are looking for is Craft::$app->getRequest()->getIsCpRequest()
8
votes
Is there a native function or plugin to allow admins to email all users?
Currently there isn't a native function to do this.
The only plugin that I know of that can do this, is Sprout Email from Barrel Strength Design.
EDIT:
I just released a plugin called Craft-Mailer ...
8
votes
Accepted
How do I reset a user’s password or email them when I create an account?
If you are an administrator or your account has “administrate users” privileges, then there is a checkbox on the user’s edit page in the control panel that says “Require Password Reset on Next Login” ...
8
votes
Accepted
Customize activation and other system emails
Actually Brad, I was able to figure out a way to do this with some help from @carlcs in the slack channel.
I defined an "HTML Template" in the main email settings screen, then in that template I ...
7
votes
Accepted
How do I send an email to multiple recipients?
You can loop through a list of your recipients:
// Comma-separated list of recipients
$recipients = 'person1@example.com, person2@example.com';
// Break out recipients into an array
$recipientList = ...
7
votes
Accepted
Email Notification When Post Submitted
Currently there isn't a native way to do this, but you could write a plugin which would work like this:
Wait for an event like: content.onSaveContent or entries.onSaveEntry
Get all users from a ...
7
votes
Accepted
Is there a native function or plugin to allow admins to email all users?
Natively, there is no direct way to do this. It is possible, however, to easily create this functionality with a plugin...
Build an
ElementCriteriaModel
which will return a list of all users. ...
7
votes
Accepted
How to use the default HTML email template when sending an email from a plugin?
There are different ways
Extending the E-mail template in your template
This could be your email template emails/_someMail
{% extends 'path/of/your/layout-same-as-you-inserted-in-your-cp' %}
{% ...
6
votes
Email Notification When Post Submitted
For those that are looking for a plugin that simply notifies users (without all the overhead), take a look at Brief. It's a super-light plugin that simply notifies users whenever a new entry is added ...
6
votes
Accepted
Is there a way to detect if a action is triggered from a control panel form?
Yes there is, craft()->request->isCpRequest() returns whether the request is from the CP or not.
6
votes
How to build a transactional email platform with Craft
This answer will focus on using Sprout Email for transactional emails.
Transactional Emails
First, a comment on semantics. I feel the question above is drawing a distinction between two types of ...
5
votes
Error when rendering a template (for HTML email) on users.saveUser
The issue turned out to be the result of a variable name mistake on my part. I had typed in an incorrect variable name in the email template. I actually still don't really understand what that has to ...
5
votes
Accepted
Adding CC to contact form plugin
From that code snippet, it looks like you're needing nested arrays. Try setting your $email->cc property like this.
$email->cc = array(
array('name' => 'Your Name', 'email' => 'name@...
5
votes
Accepted
Automatically subscribe users to MailChimp list?
Install the MailChimp Subscribe plugin and add the following users.onActivateUser event listener to your site’s Business Logic plugin.
craft()->on('users.onActivateUser', function(Event $event) {
...
5
votes
Mailgun (SMTP) + Craft
Craft is just passing on the error message it gets back when trying to connect with whatever settings it was given.
And we're using Mailgun ourselves (port 587) for sending emails on https://craftcms....
4
votes
Accepted
Activate account email {{link}}
OK, just did a quick look through the docs. Appears that this can be set via the config file.
Link to documentation
There's also the option to set whether the user is logged in automatically.
4
votes
Email Notification When Post Submitted
Alternatively, you could get in touch with Ben Parizek of Barrel Strength Design who has a plugin called Sprout Email. Currently in beta but you can request a preview.
I am using it as we speak.
4
votes
What can we do to help avoid member activation emails going to spam?
This the best article I've read on reliably delivering emails through code: http://blog.codinghorror.com/so-youd-like-to-send-some-email-through-code/
4
votes
Using Mailgun with Craft
The asker was able to solve their question and confirm that MailGun can be used with Craft. In the comment they state:
Just FYI: requiring vendor/autoload.php (from my plugin) worked and
...
4
votes
Accepted
Is it possible to have Craft send an email on page load?
I would think you would want to instead set up a controller action, as URLs route directly to them, rather than use the overhead of a page.
Your cron job could hit the corresponding Controller Action ...
4
votes
Accepted
Sending email by key to non-user
Just because EmailService::sendEmailByKey() requires you to pass in a UserModel, doesn’t mean that the model has to represent an actual saved user. You can create one on the spot for them:
$user = ...
4
votes
Accepted
Controlling where user is sent if clicking old or expired email activation link
It looks like the config setting activateAccountFailurePath is what you are looking for.
4
votes
Accepted
Change system settings email address
I think you are referring to the System Email Address under "Settings" -> "E-mail" -> "System Email Address".
4
votes
Accepted
Email subscriptions system
Sounds quite do-able. I will first admit I don't know how postmaster works at all, so I could be way off in my suggestion. Regardless, you're looking at two plugins working together; a contact form &...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
emails × 196plugin-development × 32
craft3 × 27
users × 25
plugins × 15
registration × 13
activation × 13
templating × 11
plugin-craftcommerce × 11
plugin-contactform × 10
form × 8
plugin-sproutemail × 7
config × 6
plugin-sproutforms × 6
plugin-freeform × 5
settings × 5
modules × 4
user-profile × 4
plugin-craftcommerce3 × 4
control-panel × 3
events × 3
craft2 × 3
frontend-form × 3
order × 3
status × 3