Ask HN: Create an app that sends an email with some text

5 pointsposted 9 months ago
by thr0waway1

Item id: 41622390

18 Comments

panosfilianos

9 months ago

Maybe someone is more knowledgable but I think the biggest issue here is deliverability.

You'll probably have to use a reputable provider's API (eg. GMail, Twilio etc.) because otherwise the recipients' provider are likely to flag you as spam and people never see your email.

xupybd

9 months ago

Most email providers have APIs now. This is probably one rest call. Super easy in most languages.

  Pick a language.
  Pick an email as a service. 
  Read the docs. 
  Extend an example for your needs
  Set-up your cron job

  Profit

librasteve

9 months ago

In raku,

  use Net::SMTP;

  Net::SMTP.new('smtp.gmail.com', port => 587, ssl => True)

  .login('your-email@gmail.com', 'your-password')
  .send(
    :from('your-email@gmail.com'),
    :to('recipient@example.com'), 
    :subject('Daily Snippet'),   
    :body('A random snippet'))
  .quit;
Then,

  crontab -e
  0 4 * * * /path/to/raku /path/to/send-email.raku

asciimov

9 months ago

This sounds like a CS 102 homework assignment. Break out a book on bash scripting an get to hacking.

masteruvpuppetz

9 months ago

If you're Microsoft 365 subscriber, then u can set up a PowerAutomate job.

Benefit of this route is lots of youtube tutorials explaining this and written documentation.

Hope this helps.

solardev

9 months ago

Can you be more specific about this "database/data store"? The nature of that will limit your options.

If it's just a big ol' CSV or something similar, you might be able to just use a nocode/lowcode tool like Airtable or Make.com to automate it in a few minutes.

If it's something particular SQL database that you need to write a query to extract data from, it gets a bit harder because you need to connect that layer to the automation layer and then connect that to a transactional email service with good deliverability.

If you can give a clearer picture of details, like what kind of data format it's in, how many people you need to send it to, how often will the underlying data change, etc., it would help narrow down the options. There are approx. infinite ways to build this, but it can be very simple or more complicated depending on the details.

porlw

9 months ago

This can easily be done with a small shell script and standard linux commands.

   #!/usr/bin/bash
   
   MAILTEXT=$(grep "dbkey" db.txt)
   
   cat emails.lst|while read ADDR NAME
   do
      mail -s "Subject" $ADDR <<EOT
   Dear $NAME

   $MAILTEXT

   EOT
   
   done
Schedule with cron.

nh2

9 months ago

This is unsafe (glob injection).

Never use bash unless you know exactly what you are doing, and even then, better don't.

Even worse to recommend bash to somebody who already stated that they don't know what they are doing.

Just use Python for such scripts, it won't let you shoot yourself into the foot with surprising behavior.

antonzorin

9 months ago

After the question I wonder what do you mean by technical PM?

perteraul

9 months ago

While all of the answers are valid, another option that I don't see here is n8n. I used it for something very similar to your requirement and was able to run it for years without intervention.

henricourdent

9 months ago

Windmill.dev can do that easily. You can set a cron schedule to trigger a flow that does exactly what you want. If you are not a programmer, you can pick scripts (steps of the flow) from existing list Windmill Hub library (example to send an email) and use AI for the code of your actual business logic (the database part). Apart from that, you don't have to worry about code and maintenance. It's self-hostable or for less than 1k executions per month, you can use the cloud version for free.

oulipo

9 months ago

I would suggest either a platform like hosted Windmill.dev or other,

or val.town which has an AI assitant so you can use it even if you don't code

nbbaier

9 months ago

I came to say val.town. It's trivial to do what you want to do

orionblastar

9 months ago

In 1995 I made an MS Access database that had emails in a table and used MAPI with Eudora Pro to send emails. I called the database SPAM, Software Programmable Automatic Spammer. I refuse to make any more SPAM programs.

kkfx

9 months ago

Well... In app terms you ask for a cronjob and msmtp wrapped in a simple script... The hard part for you would be not being in most spam list in few hours.

slater

9 months ago

1) get a cheap-o webhost that offers cron job support

2) learn some PHP + MySQL

3) Use PHP's built-in 'mail()' function to send an e-mail

4) Set up a cron job that runs the PHP file at 4AM

sfmz

9 months ago

DB trigger plus a call to Gmail API? o1 can probably handle that.

michelsedgh

9 months ago

Yes o1 is really good even claude could do something like this, o1 just does it faster. I have made much more complex apps using both clause and now o1 cause o1 is faster, claude took me a lotta time but its absolutely possible. very easy actually. Good luck.