Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@ mailtrap messages spam-score --sandbox-id 12345 --id 67890
# Domains
mailtrap domains list
mailtrap domains create --name "yourdomain.com"
mailtrap domains update --id 123 --open-tracking --click-tracking --tracking-opt-out
mailtrap domains send-setup-instructions --id 123 --email "admin@yourdomain.com"

# Company info (required for domain compliance verification)
mailtrap company-info get --domain-id 123
mailtrap company-info create --domain-id 123 --name "Your Company" --address "123 Main St" \
--city "San Francisco" --country US --zip-code 94105 --website-url "https://yourdomain.com"
mailtrap company-info update --domain-id 123 --city "New York" --zip-code 10001

# Templates
mailtrap templates list
mailtrap templates create --name "Welcome" --subject "Hello {{name}}" --body-html '<h1>Hi!</h1>'
Expand Down Expand Up @@ -161,7 +168,8 @@ mailtrap domains list --output text
|-------|----------|
| **Sending** | `send transactional`, `send bulk`, `send batch-transactional`, `send batch-bulk` |
| **Sandbox Send** | `sandbox-send single`, `sandbox-send batch` |
| **Domains** | `domains list`, `domains get`, `domains create`, `domains delete`, `domains send-setup-instructions` |
| **Domains** | `domains list`, `domains get`, `domains create`, `domains update`, `domains delete`, `domains send-setup-instructions` |
| **Company Info** | `company-info get`, `company-info create`, `company-info update` |
| **Templates** | `templates list`, `templates get`, `templates create`, `templates update`, `templates delete` |
| **Suppressions** | `suppressions list`, `suppressions delete` |
| **Webhooks** | `webhooks list`, `webhooks get`, `webhooks create`, `webhooks update`, `webhooks delete` |
Expand Down
18 changes: 10 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ import (
"github.com/mailtrap/mailtrap-cli/internal/commands/accounts"
"github.com/mailtrap/mailtrap-cli/internal/commands/attachments"
"github.com/mailtrap/mailtrap-cli/internal/commands/billing"
"github.com/mailtrap/mailtrap-cli/internal/commands/companyinfo"
"github.com/mailtrap/mailtrap-cli/internal/commands/configure"
"github.com/mailtrap/mailtrap-cli/internal/commands/contact_fields"
"github.com/mailtrap/mailtrap-cli/internal/commands/contact_lists"
"github.com/mailtrap/mailtrap-cli/internal/commands/configure"
"github.com/mailtrap/mailtrap-cli/internal/commands/contacts"
"github.com/mailtrap/mailtrap-cli/internal/commands/domains"
email_logs "github.com/mailtrap/mailtrap-cli/internal/commands/email_logs"
"github.com/mailtrap/mailtrap-cli/internal/commands/emailcampaigns"
"github.com/mailtrap/mailtrap-cli/internal/commands/inbound"
"github.com/mailtrap/mailtrap-cli/internal/commands/sandboxes"
"github.com/mailtrap/mailtrap-cli/internal/commands/messages"
"github.com/mailtrap/mailtrap-cli/internal/commands/organizations"
"github.com/mailtrap/mailtrap-cli/internal/commands/permissions"
"github.com/mailtrap/mailtrap-cli/internal/commands/projects"
"github.com/mailtrap/mailtrap-cli/internal/commands/sandbox_send"
"github.com/mailtrap/mailtrap-cli/internal/commands/sandboxes"
"github.com/mailtrap/mailtrap-cli/internal/commands/send"
"github.com/mailtrap/mailtrap-cli/internal/commands/stats"
"github.com/mailtrap/mailtrap-cli/internal/commands/suppressions"
Expand All @@ -35,9 +36,9 @@ import (

func NewRootCmd(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "mailtrap",
Short: "CLI for the Mailtrap email platform",
Long: "A command-line interface for managing Mailtrap email sending, sandbox testing, contacts, and account settings.",
Use: "mailtrap",
Short: "CLI for the Mailtrap email platform",
Long: "A command-line interface for managing Mailtrap email sending, sandbox testing, contacts, and account settings.",
SilenceUsage: true,
SilenceErrors: true,
}
Expand All @@ -56,6 +57,7 @@ func NewRootCmd(f *cmdutil.Factory) *cobra.Command {

// Sending Management
cmd.AddCommand(domains.NewCmdDomains(f))
cmd.AddCommand(companyinfo.NewCmdCompanyInfo(f))
cmd.AddCommand(suppressions.NewCmdSuppressions(f))
cmd.AddCommand(stats.NewCmdStats(f))
cmd.AddCommand(templates.NewCmdTemplates(f))
Expand Down Expand Up @@ -96,9 +98,9 @@ func NewRootCmd(f *cmdutil.Factory) *cobra.Command {

func newCompletionCmd() *cobra.Command {
return &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion scripts",
Args: cobra.ExactArgs(1),
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion scripts",
Args: cobra.ExactArgs(1),
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
RunE: func(cmd *cobra.Command, args []string) error {
switch args[0] {
Expand Down
54 changes: 54 additions & 0 deletions internal/commands/companyinfo/companyinfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package companyinfo

import (
"github.com/mailtrap/mailtrap-cli/internal/cmdutil"
"github.com/mailtrap/mailtrap-cli/internal/output"
"github.com/spf13/cobra"
)

type CompanyInfo struct {
Name *string `json:"name,omitempty"`
Address *string `json:"address,omitempty"`
City *string `json:"city,omitempty"`
Country *string `json:"country,omitempty"`
Phone *string `json:"phone,omitempty"`
ZipCode *string `json:"zip_code,omitempty"`
PrivacyPolicyURL *string `json:"privacy_policy_url,omitempty"`
TermsOfServiceURL *string `json:"terms_of_service_url,omitempty"`
WebsiteURL *string `json:"website_url,omitempty"`
InfoLevel *string `json:"info_level,omitempty"`
}

type companyInfoResponse struct {
Data CompanyInfo `json:"data"`
}

var companyInfoColumns = []output.Column{
{Header: "NAME", Field: "name"},
{Header: "ADDRESS", Field: "address"},
{Header: "CITY", Field: "city"},
{Header: "COUNTRY", Field: "country"},
{Header: "ZIP CODE", Field: "zip_code"},
{Header: "PHONE", Field: "phone"},
{Header: "WEBSITE", Field: "website_url"},
{Header: "PRIVACY POLICY", Field: "privacy_policy_url"},
{Header: "TERMS OF SERVICE", Field: "terms_of_service_url"},
{Header: "INFO LEVEL", Field: "info_level"},
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

func companyInfoPath(domainID string) string {
return "/api/domains/" + domainID + "/company_info"
}

func NewCmdCompanyInfo(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "company-info",
Short: "Manage sending domain company info",
}

cmd.AddCommand(NewCmdGet(f))
cmd.AddCommand(NewCmdCreate(f))
cmd.AddCommand(NewCmdUpdate(f))

return cmd
}
Loading
Loading