Phase 2 part 6: outreach by email and LinkedIn

Drafts are written by the AI from the person's buying signal (hypothesis
and angle), their company and their history, then reviewed and edited.
Queued emails go out through the Core's mail server one at a time, within
the sending hours, the daily limit and a gap, never to a suppressed or
bouncing address or someone emailed in the last 14 days; with a signature,
an opt-out line, UTM-tagged links and a copy in Sent. The inbox is read
read-only every 10 minutes: replies (by Message-ID or sender) count as
Replied, bounces mark the address, and "stop" replies are suppressed.
LinkedIn messages are copied, sent by hand and marked sent. New pages:
Prospects → Outreach and Settings → Email (with an SMTP, IMAP, SPF, DKIM
and DMARC check). Schema 10; emersion/go-imap for IMAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 06:09:47 -07:00
co-authored by Claude Opus 5.5
parent 82d569da9c
commit c2772a7927
26 changed files with 3079 additions and 3 deletions
+119
View File
@@ -0,0 +1,119 @@
{{define "content"}}{{with .Data}}{{$d := .}}{{$tab := .Tab}}
<div class="heading">
<h1>Outreach</h1>
<div class="buttons">
{{if not .NotReady}}<form method="post" action="/outreach/check" data-busy="Reading…"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary">Check for replies</button></form>{{end}}
</div>
</div>
<p class="lede">Emails and LinkedIn messages to the people you accepted, each written from their buying signal's angle. Read and edit every draft: emails you queue go out one at a time, within your sending hours and daily limit; LinkedIn messages you send yourself. Replies, bounces and requests to stop come back from the inbox into the funnel.</p>
<section class="card status-line">
{{if not .Configured}}<p class="warn-text">Set up the mailbox under <a href="/settings/email">Settings → Email</a> before queuing emails. You can draft already.</p>
{{else if .NotReady}}<p class="warn-text">Sending is off: {{.NotReady}}.</p>
{{else}}
<p><strong>{{.SentToday}}</strong> of {{.S.DailyLimit}} emails sent today{{with .Counts.queued}}, <strong>{{.}}</strong> queued{{end}}. {{if .Window}}Paused: {{.Window}}.{{else}}Sending now, one every {{.S.GapMinutes}} minutes or more.{{end}}</p>
{{with .LastCheck}}<p class="small muted">Inbox read {{ago .At}}{{if .Error}}: <span class="error-text">{{.Error}}</span>{{else}}: {{.Read}} new {{if eq .Read 1}}message{{else}}messages{{end}}{{if .Replies}}, {{.Replies}} {{if eq .Replies 1}}reply{{else}}replies{{end}}{{end}}{{if .Bounces}}, {{.Bounces}} bounced{{end}}{{if .Stops}}, {{.Stops}} asked to stop{{end}}{{if .AutoReplies}}, {{.AutoReplies}} automatic{{end}}.{{end}}</p>{{end}}
{{end}}
</section>
{{if or .Emailable .Linkable}}
<form method="post" action="/outreach/draft-many" class="card row wrap" data-busy="Writing…">
<span>Write to accepted people nobody has written to yet ({{.Emailable}} with an email address, {{.Linkable}} on LinkedIn), 5 at a time:</span>
<select name="channel"><option value="email">Email</option><option value="linkedin">LinkedIn</option></select>
{{if .Signals}}<select name="signal"><option value="0">any signal</option>{{range .Signals}}<option value="{{.ID}}">{{.Name}}</option>{{end}}</select>{{end}}
<button type="submit" class="secondary small">Draft</button>
</form>
{{end}}
<nav class="tabs">
{{range .Tabs}}<a href="/outreach?tab={{.ID}}" {{if eq $tab .ID}}aria-current="page"{{end}}>{{.Label}}{{with index $d.Counts .ID}} <span class="muted">{{.}}</span>{{end}}</a>{{end}}
</nav>
{{range .Messages}}{{$m := .}}
<section class="card message" id="m-{{.ID}}">
<div class="prospect-head">
<div>
<h2>{{.Contact.Name}}{{with .Contact.Title}} <span class="muted small">{{.}}</span>{{end}}{{with .Company}} <span class="muted small">at {{.}}</span>{{end}}</h2>
<p class="meta">
<span class="badge">{{if eq .Channel "email"}}Email{{else}}LinkedIn{{end}}</span>
{{if eq .Channel "email"}}{{.To}}{{if eq .Contact.EmailStatus "valid"}} <span class="badge published">verified</span>{{else if eq .Contact.EmailStatus "risky"}} <span class="badge">risky</span>{{else if eq .Contact.EmailStatus "invalid"}} <span class="badge failed">bounces</span>{{else}} <span class="muted">not verified</span>{{end}}
{{else}}<a href="{{.Contact.LinkedIn}}" target="_blank" rel="noopener noreferrer">LinkedIn profile ↗</a>{{end}}
{{with index $d.SignalNames .SignalID}} · signal <strong>{{.}}</strong>{{end}}
· written {{ago .CreatedAt}}{{if not .SentAt.IsZero}} · sent {{ago .SentAt}}{{end}}
</p>
</div>
</div>
{{if eq .Status "draft"}}
{{if eq .Channel "email"}}
<form method="post" action="/outreach/{{.ID}}/save">
<input type="hidden" name="tab" value="{{$tab}}">
<label>Subject <input name="subject" value="{{.Subject}}"></label>
<label>Email <textarea name="body" rows="9">{{.Body}}</textarea>
<span class="help">Your signature and the opt-out line are added under it. Links to your sites get UTM tags for this signal.</span></label>
<div class="actions">
<button type="submit" formaction="/outreach/{{.ID}}/queue">Queue to send</button>
<button type="submit" class="secondary">Save</button>
<button type="submit" class="secondary" formaction="/outreach/{{.ID}}/discard" data-confirm="Discard this draft?">Discard</button>
</div>
</form>
{{else}}
<form method="post" action="/outreach/{{.ID}}/mark-sent">
<input type="hidden" name="tab" value="{{$tab}}">
<label>Message <textarea name="body" id="li-{{.ID}}" rows="6" maxlength="{{$d.Limit}}" data-count="linkedin" data-limit="{{$d.Limit}}" aria-describedby="li-count-{{.ID}}">{{.Body}}</textarea>
<p class="count" id="li-count-{{.ID}}"></p>
<span class="help">Copy it, open their profile, and send it there (as a message, or a note with a connection request); then mark it sent.</span></label>
<div class="actions">
<button type="button" class="secondary" data-copy="li-{{.ID}}">Copy</button>
<a class="button secondary" href="{{.Contact.LinkedIn}}" target="_blank" rel="noopener noreferrer">Open their profile ↗</a>
<button type="submit">Mark as sent</button>
<button type="submit" class="secondary" formaction="/outreach/{{.ID}}/save">Save</button>
<button type="submit" class="secondary" formaction="/outreach/{{.ID}}/discard" data-confirm="Discard this draft?">Discard</button>
</div>
</form>
{{end}}
{{else if eq .Status "queued"}}
{{template "message-text" .}}
<div class="actions">
<form method="post" action="/outreach/{{.ID}}/send-now" data-busy="Sending…"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="small">Send now</button></form>
<form method="post" action="/outreach/{{.ID}}/unqueue"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Back to drafts</button></form>
</div>
{{else}}
{{template "message-text" .}}
{{with .Error}}<p class="{{if eq $m.Status "sent"}}warn-text{{else}}error-text{{end}} small">{{.}}</p>{{end}}
{{if not .RepliedAt.IsZero}}
<div class="reply"><p class="small muted">They replied {{ago .RepliedAt}}:</p><blockquote>{{.Reply}}</blockquote></div>
{{else if and (eq .Status "sent") (eq .Channel "linkedin")}}
<details class="outcome"><summary class="small">They replied</summary>
<form method="post" action="/outreach/{{.ID}}/replied" class="row wrap">
<input type="hidden" name="tab" value="{{$tab}}">
<label class="small grow">What they said <input name="reply" placeholder="optional"></label>
<button type="submit" class="secondary small">Record the reply</button>
</form>
</details>
{{end}}
{{if eq .Status "failed"}}
<div class="actions">
<form method="post" action="/outreach/{{.ID}}/queue"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Queue again</button></form>
<form method="post" action="/outreach/{{.ID}}/discard"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Discard</button></form>
</div>
{{end}}
{{end}}
</section>
{{else}}
<section class="card empty">
{{if eq $tab "draft"}}<p>No drafts. Write one from a person in <a href="/prospects?status=accepted">Review</a>, or draft for several accepted people above.</p>
{{else if eq $tab "queued"}}<p>Nothing queued.</p>
{{else if eq $tab "sent"}}<p>Nothing sent yet.</p>
{{else if eq $tab "replied"}}<p>No replies yet.</p>
{{else}}<p>Nothing failed or bounced.</p>{{end}}
</section>
{{end}}
{{end}}{{end}}
{{define "message-text"}}
{{if .Subject}}<p><strong>{{.Subject}}</strong></p>{{end}}
<div class="message-body">{{.Body}}</div>
{{end}}