3

I need to take a file, and email it to a large group of people. Naturally, I'll be using a custom plugin Controller to trigger the email blast.

I'm already aware of this similar thread, but I don't believe it will solve my problem. If I remember correctly, Craft's native email model isn't capable of sending to more than one person at a time. More importantly, I don't want our server to be labeled as a spammer!

Would it make sense to run this process through a Task? Each individual email could be sent out as a separate step in the task.

What is the best way to bulk email an attachment?

  • 1
    Not sure if it's relevant... The site is using Mailgun SMTP to send emails. – Lindsey D Mar 23 '16 at 5:49
  • Can't you just setup a CRON that sends 10 emails every 1 minute from a Plugin Controller w/ the attachment? – naboovalley Mar 23 '16 at 16:26
  • Is that the best way? That's what I'm trying to find out. Sending an email every 6 seconds seems like an improvement, but I'm certainly no email/spam expert. – Lindsey D Mar 23 '16 at 16:34
  • 1
    How many emails? If you're using mailgun, I wouldn't fuss too much about rate limiting since they will be doing it on their end. I'm assuming you're sending via api and not smtp? If you were doing this on any old server directly to the recipient, then yeh you got a huge kill list to get it working (ptr and spf dns records, etc). Mailgun is 300 requests per min – RitterKnight Mar 25 '16 at 5:24
  • Oops wrong link. If you batch your emails you can rattle off 1000 per batch. – RitterKnight Mar 25 '16 at 5:37
4

There's nothing that says you have to go through Craft's EmailModel/EmailService for this.

Craft ultimately uses the PHPMailer library, so you can instantiate it directly and use whatever settings you need (or use a completely different library).

I assume you don't want to cram everyone into to "To Address", so is the plan to set the "To Address" to yourself and BCC the recipient list?

Depending on the number of emails you need to send, I'd probably just have your plugin read from the file and insert into a database table. Then you could setup a cron job to hit your plugin's controller action to send out (one at a time) X emails over Y time period and delete those from the table until its empty.

As far as not getting flagged as a SMTP relay, in addition to throttling email rates, there are definitely other things you can do to reduce your chances.

| improve this answer | |
4

As someone who's run a mail server professionally, thought I'd expand on a comment. Brad's answer goes over the technical details of sending with Craft, I suppose this answer is more "philosophical"?

Back many years ago, I'd send newsletters "manually" (using PHPList, pommo, my own home brewed set-up... shudders, etc), these were only a few hundred to a thousand. I'd deal with the bounce backs, vacation notices, etc. manually. Fun stuff.

These days, it's gotten a bit more complex. As an aside, if you were doing this on any old server directly to the recipient, then you have to worry about reverse DNS (ptr) and SPF DNS records, probably DKIM if you want to round your bases.

Thankfully we have services that handle much of the BS of making sure your e-mail is actually delivered.

The big questions are really how many emails do you have to send, what are you actually sending, and how big is the attachment?

Stuff I'd worry about:

  • Attachments are huge spam flags. If you're sending the same one to every person, is there a way to put that on the server with a link to what you're sending? Or is the attachment also dynamically generated? If it were me, I'd probably set up the attachment on the server with a link to attachment but I can see where you might have to actually attach something.

  • Rate limiting. If you're using MailGun, I wouldn't worry too much about rate limiting since they will be doing the "reputation" management on their end so you won't flood the destination mail servers.

    If these are B2B e-mail addresses, it's a bit easier since many run individual Exchange boxes so you won't be bumping up against ISP based e-mail accounts—Google Apps, Zoho, etc. probably being the exceptions.

  • Are you sending more of a newsletter or "transactional" style e-mail? The latter is everyone gets something slightly different like an order confirmation, upsell, etc.

    If you're using Craft like an e-mail newsletter creator (I can see Matrix being awesome for this), you may be better off interfacing with MailChimp, Aweber, Campaign Monitor, etc. Use their APIs to feed the e-mail data into that software that way and then send it off. They are better optimized in a one-to-many situation like and can track deliverability for an e-mail blast versus Amazon SES, Mandrill, etc. are more optimized for one-to-one transactional e-mails. It's a subtle difference but it can mean the world of difference for deliverability.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.