问题
Today when I'm sending basic emails, I use a "Mail" class which is a custom wrapper using SwiftMailer, like so :
<?php
Mail::create('Message title')
->template('Template string or view path. Global variable "var" is "{var}". Current user is {username}.')
->tags(array('var' => 'value 1'))
->from('contact@mydomain.com')
->to('mail@example.com', array('username' => 'Boris'))
->transport(Mail::SMTP)
->send();
It works fine for basic emails but can't be used to send newsletters for multiple reasons :
- No pool management
- No deferred sending
- No tracking
So I thought about a way to centralize more complex email management. I made a schema :
I don't want the distant server to store any contact information, only campaigns, recipients and statistics, like the following diagram:
The "data" field of the "Recipient" table is here to store custom data structure that will be sent back when the API is asked for information about a recipient. For example :
<?php
$result = NewsletterAPI::getRecipientsViewReport($campaignRef);
//
// Will contain something like :
// Array
// (
// [recipients] => Array
// (
// [0] => Array
// (
// [email] => toto@gmail.com
// [opened] => 3
// [last_open_date] => '2015-02-02 12:32:23',
// [data] => Array
// (
// [id] => 123
// )
// )
// [1] => Array
// (
// [email] => tata@hotmail.com
// [opened] => 0
// [last_open_date] => null,
// [data] => Array
// (
// [id] => 17
// )
// )
// )
// )
The distant server doesn't care about anything else than sending emails and getting statistics on them. No matter what entities are behind email addresses or how users are managed.
It only prevent a user to access data it doesn't own, and prevent non admin users to access admin API methods (like create users).
This way it's very easy to integrate in any website, I just have to store the api key of the account I want to send mail with (like adding a "mailing_api_key" field in my "User" entity for example).
So my question
First of all, what do you think about this architecture ?
In real world usage, the amount of emails should not be very huge (few thousands a week), but I would like the system to be a minimum robust.
Aside of that, there are three main problems that I can think of :
- Being blacklisted,
- Have bad statistics results because I don't know any other way to track views than using a tracking image and it's very easy to block,
- Detect bounces seems pretty complex from what I've read and I've no experience with it.
So I've done some researches to find specialized services which can handle this, like :
- Mailchimp
- Sendinblue
- MPZMail
- Campayn
- FreshMail
and so on.. But all of them wants to manage contacts and a lot of things I don't care of.
I just want a service with no UI at all, that do something close to what I've described above:
- Dynamic account creation (only for admin account),
- Send emails to a custom list of addresses each time, with no limit and no pre-created mailing list of any sort,
- Easy way to get :
- list of campaigns (of the user doing the request),
- statistics of a campaign,
- statistics for specific address,
- and.. that's all !
Thank you very much if you've read it all, I hope to find a solution.
Regards.
回答1:
Most (big) companies just use a third party API like mailchimp. Just subscribe to a few company newsletter and look at the email header.
There is a reason if companies with a budget over millions will use thirdparty newsletter companies. You will have a lot of trouble with spam filters and problems you do not know yet ... there are even different laws in different countries. (example: in germany you must provide an unsubscribe link within the email).
those third party newsletter companies provide an api that you can integrate in php.
来源:https://stackoverflow.com/questions/28876040/most-efficient-way-to-send-newsletters