# SMTP

Send through SMTP when your app or tool cannot call the API. Each message goes through the same checks, limits and logs as `POST /v1/emails`.

## Connection Settings

| Setting  | Value                                       |
| -------- | ------------------------------------------- |
| Host     | `smtp.inboxjot.com`                         |
| Port     | 465 with SSL, or 587 and 2525 with STARTTLS |
| Username | `inboxjot`                                  |
| Password | An API key with Sending access              |
| Auth     | PLAIN or LOGIN, after TLS starts            |

```javascript Node.js
import nodemailer from 'nodemailer';

const transport = nodemailer.createTransport({
  host: 'smtp.inboxjot.com',
  port: 465,
  secure: true,
  auth: { user: 'inboxjot', pass: process.env.INBOXJOT_API_KEY },
});

await transport.sendMail({
  from: 'Acme <hello@send.acme.dev>',
  to: 'riti@example.com',
  subject: 'Your receipt from Acme',
  html: '<p>Thanks for your order.</p>',
});
```

```rust Rust
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};

let email = Message::builder()
    .from("Acme <hello@send.acme.dev>".parse()?)
    .to("riti@example.com".parse()?)
    .subject("Your receipt from Acme")
    .body(String::from("Thanks for your order."))?;

let mailer = SmtpTransport::relay("smtp.inboxjot.com")?
    .credentials(Credentials::new(
        "inboxjot".to_owned(),
        std::env::var("INBOXJOT_API_KEY")?,
    ))
    .build();

mailer.send(&email)?;
```

```go Go
auth := smtp.PlainAuth("", "inboxjot", os.Getenv("INBOXJOT_API_KEY"), "smtp.inboxjot.com")
message := []byte("From: Acme <hello@send.acme.dev>\r\n" +
	"To: riti@example.com\r\n" +
	"Subject: Your receipt from Acme\r\n" +
	"\r\n" +
	"Thanks for your order.\r\n")

err := smtp.SendMail(
	"smtp.inboxjot.com:587",
	auth,
	"hello@send.acme.dev",
	[]string{"riti@example.com"},
	message,
)
```

```python Python
import os
import smtplib
from email.message import EmailMessage

message = EmailMessage()
message["From"] = "Acme <hello@send.acme.dev>"
message["To"] = "riti@example.com"
message["Subject"] = "Your receipt from Acme"
message.set_content("Thanks for your order.")

with smtplib.SMTP_SSL("smtp.inboxjot.com", 465) as smtp:
    smtp.login("inboxjot", os.environ["INBOXJOT_API_KEY"])
    smtp.send_message(message)
```

Developers › SMTP in the dashboard shows the same values. Create the key in [API Keys](https://inboxjot.com/docs/api-keys.md).

## How Messages Map

- To and Cc keep the header addresses that are also envelope recipients. Every other envelope recipient becomes Bcc.
- The From header sets the sender. Without it, the MAIL FROM address is used.
- Reply-To, the subject, the HTML and text parts and attachments carry over.
- X- headers pass through, except a few that Inboxjot reserves for delivery. In-Reply-To, References and the List-Unsubscribe headers also pass through.
- Open and click tracking follow the settings of the sending domain.
- Logs show SMTP as the source of the email.

## Limits and Replies

| Limit                  | Value                                    |
| ---------------------- | ---------------------------------------- |
| Message size           | 40 MB                                    |
| Recipients per message | 50                                       |
| Failed sign-ins        | 3, then the server closes the connection |
| Idle timeout           | 5 minutes                                |

A queued message gets `250 2.0.0 Queued as` and the email id. A rate limit gets a temporary `451` reply, so your client retries later. An auth or permission problem gets `550`, and an invalid message gets `554`.

> SMTP has no templates and no idempotency keys. Use the API for those.
