Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

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|...
user avatar
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 ...
user avatar
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. ...
user avatar
  • 66.4k
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 ...
user avatar
  • 4,509
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 ]);
user avatar
  • 2,947
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....
user avatar
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()
user avatar
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 ...
user avatar
  • 8,316
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” ...
user avatar
  • 66.4k
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 ...
user avatar
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 = ...
user avatar
  • 13.2k
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 ...
user avatar
  • 8,316
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. ...
user avatar
  • 23.6k
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' %} {% ...
user avatar
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 ...
user avatar
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.
user avatar
  • 35.8k
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 ...
user avatar
  • 13.2k
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 ...
user avatar
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@...
user avatar
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) { ...
user avatar
  • 35.8k
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....
user avatar
  • 66.4k
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.
user avatar
  • 438
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.
user avatar
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/
user avatar
  • 66.4k
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 ...
user avatar
  • 13.2k
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 ...
user avatar
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 = ...
user avatar
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.
user avatar
  • 608
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".
user avatar
  • 2,824
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 &...
user avatar
  • 4,696

Only top scored, non community-wiki answers of a minimum length are eligible