djstevenson / songs-to-the-siren

A blog about songs
MIT License
0 stars 0 forks source link

Use something free to deliver mails #216

Closed djstevenson closed 4 years ago

djstevenson commented 4 years ago

Deliver emails by some method that doesn't cost money (Mailgun is dropping the free tier).

djstevenson commented 4 years ago

The following test script shows how I can send mail that should work both on dev mac and on deployment Linode. Obvs the credentials will be set by something that's not in the repo, e.g. ENV vars:

#!/usr/bin/env perl

use strict;
use warnings;

use Net::SMTP::TLS;
my $smtp = Net::SMTP::TLS->new(
    'xxxx', # SMTP server
    NoTLS => 1,
    Hello => 'songstothesiren.com',
    Timeout =>60,
    User => 'xxxx', # auth user for SMTP server
    Password => 'xxxx', # auth pw for SMTP server
);

my $from = 'noreply@songstothesiren.com';
my $to = 'xxx@example.com',
$smtp->mail($from);
$smtp->recipient($to);
$smtp->data;
$smtp->datasend("From: ${from}\n");
$smtp->datasend("To: ${to}\n");
$smtp->datasend("Subject: This is a test\n\n");
$smtp->datasend("blahblah etc\n");
$smtp->dataend;
$smtp->quit;
djstevenson commented 4 years ago

Done in PRs #234 and #235