Effectively using Google App Engine to send lots o

2019-04-03 00:09发布

I currently have a client website on the Grid server on MediaTemple that will be moved to a Virtual Private Server soon. Currently it's using some hacks to trickle his massive email sendouts using cron jobs and queuing with the database (to avoid going over the limit MediaTemple set).

We can't use third party solutions (like MailChimp etc) as the price is just too much for the client to pay (he has 75,000+ people on his mailing list). So after lots of research, I've found that using Google App Engine as basically a scalable way to send out lots of emails is a viable option.

His site uses PHP at the moment. I do eventually want to use Python/Django, but not for the time being... There is a few things I don't quite understand... Such things as having the app called 'example.appspot.com', can this be a sub domain on his site (like mailapp.example.com)? After reading the user guide on Google App Engine it seems that the email address the app uses is an admin on the application (like admin@example.appspot.com)... that has to be that? It can't possibly be something like example@example.com?

I understand that sending out so many emails means I'll have to enable the billing on the application. I understand there is still a quota on how many I can send. I've even seen this code that could help set this up easily: http://github.com/tow/appengine-mailer

I ideally want to replace the PHP code where it sends out email (using mail() etc) and make it send out with Google App Engine instead.

Has anyone successfully done this sort of setup? Can anyone help me spell the steps required? Or provide any pitfalls to using such a system?

2条回答
叼着烟拽天下
2楼-- · 2019-04-03 00:49

Your first question:

having the app called 'example.appspot.com', can this be a sub domain on his site (like mailapp.example.com)?

Yes, as the FAQ say:

Google App Engine can be used with Google Apps to provide a custom domain name for your internet-facing application, e.g., myapp.com.

By default, when you deploy your service on Google App Engine, your service will be accessible at [your-application-id].appspot.com. In order to provide a stronger brand experience for your application, you may also want that application to be available at [my-brand].com or www.[my-brand].com.

In order to set up these branded access locations for your service, you must prove that you own the domain name or purchase the domain name through Google. Google App Engine allows you to prove ownership of your domain and purchase new domain names using Google Apps.

Your second question:

the email address the app uses is an admin on the application (like admin@example.appspot.com)... that has to be that? It can't possibly be something like example@example.com?

Sure, you can use the Google userids you want as your admin users for your apps.

I understand that sending out so many emails means I'll have to enable the billing on the application. I understand there is still a quota on how many I can send.

Yep, per the docs, $0.0001 per recipient emailed. With 75,000 people on the mailing list, that's $7.50 per mail sent to all of them. Per these other docs, the free quota is 2,000 recipients emailed per day, the absolute maximum is 7.4 millions (there also limits to the rate, i.e., how many recipients are mailed per minute in free and max quotas).

I ideally want to replace the PHP code where it sends out email (using mail() etc) and make it send out with Google App Engine instead.

Sorry, can't help you there, I run App Engine with Python, not PHP. But I hear that, with Quercus, it is possible to run PHP on the JVM "side" of App Engine.

查看更多
在下西门庆
3楼-- · 2019-04-03 01:04

You can use appengine for PHP to send mails to users this way:

<?php

    require_once 'google/appengine/api/mail/Message.php';
    use google\appengine\api\mail\Message;

    $mail_options = [
        "sender" => 'you@example.com',
        "to" => $_POST['email'],
        "subject" => "Type a subject here",
        "textBody" => "Type message here",
            ];

    try {
    $message = new Message($mail_options);
    $message->send();
    } catch (InvalidArgumentException $e) {
    echo $e;
    }

?>
查看更多
登录 后发表回答