I can send mail with PHPMailer using Google's servers. It turned out the limit of sent emails is 99/day. So I digged deeper and found that I can use Google App Engine to send emails for $0.0001 with a 1.7 millions/day limit.
I have a VPS running CentOS that I access via Putty (I have basic linux knowledge) and CPanel. I installed Python and the App Engine PHP SDK. The PHP version is 5.4.22.
I would like to send mail with the given example but I am stuck at the first line. While the php file is in the public_html folder, the appengine is installed outside:
root@server1 [~]# locate Message.php
/root/google_appengine/php/sdk/google/appengine/api/mail/Message.php
The code:
<?php
require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message;
$message_body = 'Hello. This is the body of the message.';
$mail_options = [
'sender' => 'support@mycompany.com',
'to' => 'myname@gmail.com',
'subject' => 'Your account has been activated.',
'textBody' => $message_body
];
try {
$message = new Message($mail_options);
$message->send();
} catch (InvalidArgumentException $e) {
echo 'error: ';
}
?>
So I get the obvious error:
Warning: require_once(google/appengine/api/mail/Message.php): failed to open stream: No such file or directory in /home/mycompany/public_html/test_googleappsmail.php on line 2
Furthermore, the docs are not clear if I should do anything in the Google Developer Console. I created a project but I have no idea what to do with it. All I want is to send e-mails.
Could anyone point me into the right direction and tell me how to use this code?