Odoo Outgoing Mail Server — Gmail
🇹🇭 ภาษาไทย
ขั้นตอนตั้งค่า Odoo ให้ส่งอีเมลผ่าน Gmail (Google Workspace หรือ Gmail ส่วนตัว) แบบละเอียด ตั้งแต่ต้นจนเทส Connection สำเร็จ
ดูภาพรวมการตั้งค่าอีเมลทั้งหมด → Odoo Email Configuration
สิ่งที่ต้องมีก่อน
| รายการ | รายละเอียด |
|---|---|
| Gmail account | บัญชีที่จะใช้ส่งอีเมล (เช่น [email protected]) |
| 2-Step Verification | ต้องเปิดก่อนถึงจะสร้าง App Password ได้ |
| App Password | 16-digit token สำหรับ Odoo (ไม่ใช่ password ปกติ) |
| Odoo Developer Mode | ต้องเปิดก่อนเห็นเมนู Technical |
ขั้นตอนที่ 1 — เปิด 2-Step Verification บน Gmail
- ไปที่ myaccount.google.com
- Security → 2-Step Verification
- กด Get started → ทำตามขั้นตอนจนเปิดสำเร็จ
ถ้าเปิดอยู่แล้วข้ามไปขั้นตอนที่ 2 ได้เลย
ขั้นตอนที่ 2 — สร้าง App Password
- ไปที่ myaccount.google.com
- Security → 2-Step Verification → เลื่อนลงหา App passwords
- ช่อง App name → พิมพ์
Odoo SMTP(หรือชื่ออะไรก็ได้) - กด Create
- บันทึก 16-digit token ที่ได้ไว้ให้ดี — แสดงครั้งเดียว ปิดแล้วดูไม่ได้อีก
ตัวอย่าง App Password:
abcd efgh ijkl mnop
(16 ตัวอักษร — ตอนใส่ใน Odoo ลบ space ออกได้เลย)
Google Workspace: ถ้า Admin ปิด App Passwords ไว้ → Admin Console → Security → Less secure apps → เปิดให้ user
ขั้นตอนที่ 3 — เปิด Developer Mode ใน Odoo
Settings → (scroll ล่างสุด) → Activate the developer mode
หรือเร็วกว่า: เพิ่ม ?debug=1 ต่อท้าย URL ใดก็ได้
ขั้นตอนที่ 4 — เปิด Custom Email Servers
Settings → General Settings → Discuss
☑ Use Custom Email Servers
→ Save
ขั้นตอนที่ 5 — เพิ่ม Outgoing Mail Server
Path: Settings → Technical → Email → Outgoing Mail Servers → New
ใส่ค่าดังนี้:
| Field | ค่าสำหรับ Gmail |
|---|---|
| Name | Gmail SMTP (หรือชื่อที่ต้องการ) |
| SMTP Server | smtp.gmail.com |
| SMTP Port | 587 |
| Connection Security | STARTTLS |
| Username | อีเมล Gmail เต็ม เช่น [email protected] |
| Password | App Password 16 หลัก (ไม่ใช่ password Gmail ปกติ) |
| Priority | 10 (default) |
→ กด Save
→ กด Test Connection
ผลลัพธ์ที่คาดหวัง:
- ✅
Connection Test Succeeded!= ตั้งค่าถูกต้อง - ❌ Error → ดู Troubleshooting ด้านล่าง
ขั้นตอนที่ 6 — ตั้ง Default From Address (แนะนำ)
เพื่อให้อีเมลทุกฉบับออกจาก address เดียวกัน:
Settings → General Settings → Discuss
Default From Email: [email protected]
→ Save
ขั้นตอนที่ 7 — ตั้งค่า DNS เพื่อป้องกัน Spam (สำคัญมาก)
ถ้าส่งจาก custom domain เช่น yourcompany.com ต้องตั้ง DNS:
SPF Record
TXT @ "v=spf1 include:_spf.google.com include:_spf.odoo.com mx ~all"DKIM Record
ดึง key จาก Gmail:
Google Admin Console → Apps → Google Workspace → Gmail
→ Authenticate email → Generate new record
แล้วนำ TXT record ไปเพิ่มที่ DNS ของ domain
DMARC Record
TXT _dmarc "v=DMARC1; p=quarantine; rua=mailto:[email protected]"✅ ตั้ง SPF + DKIM ก่อนใช้งานจริงเสมอ — ถ้าไม่มีอีเมลจาก Odoo จะตก Spam
Troubleshooting Gmail
| อาการ | สาเหตุ | วิธีแก้ |
|---|---|---|
Authentication failed | ใส่ password Gmail ปกติ | ต้องใช้ App Password เท่านั้น |
App passwords ไม่มีให้กด | ยังไม่ได้เปิด 2-Step Verification | เปิด 2FA ก่อน |
| App Password option หายไป | Google Workspace Admin ปิดไว้ | แจ้ง Admin เปิด App Passwords |
Connection refused on port 587 | Firewall block | ลอง port 465 + SSL/TLS แทน |
| ส่งได้แต่ตก Spam | SPF/DKIM ยังไม่ตั้ง | เพิ่ม DNS records |
| ส่งได้แต่ชื่อผู้ส่งไม่ถูก | Default From ไม่ได้ตั้ง | ตั้ง Default From Address |
| อีเมลค้างใน queue | Scheduled action หยุด | Settings → Technical → Automation → Scheduled Actions → เช็ค Email Queue Manager |
ดู Email ที่ส่งออกไปแล้ว
Settings → Technical → Email → Emails
ดู status:
- Sent = ส่งสำเร็จ
- In Queue = รอส่ง
- Exception = error → กดดูเพื่ออ่าน error message
สรุปขั้นตอนแบบย่อ
1. Gmail: เปิด 2FA → สร้าง App Password (16 หลัก)
2. Odoo: เปิด Developer Mode
3. Odoo: Settings → General Settings → Discuss → ☑ Use Custom Email Servers
4. Odoo: Settings → Technical → Email → Outgoing Mail Servers → New
SMTP: smtp.gmail.com | Port: 587 | STARTTLS
Username: [email protected] | Password: [App Password]
5. Test Connection → ✅
6. ตั้ง SPF/DKIM DNS records
Related
- Odoo Email Configuration — ภาพรวมทั้งหมด: SMTP, IMAP, Alias, DNS
- Odoo General Settings — Custom Email Servers toggle, Default From
- Odoo Helpdesk — รับ ticket ผ่าน email alias
- Odoo CRM — สร้าง lead จาก incoming email
🇬🇧 English
Step-by-step guide to configure Odoo to send email via Gmail (Google Workspace or personal Gmail).
For the full email configuration overview → Odoo Email Configuration
Prerequisites
| Item | Details |
|---|---|
| Gmail account | The account that will send emails (e.g. [email protected]) |
| 2-Step Verification | Must be enabled before you can create an App Password |
| App Password | 16-character token for Odoo (NOT your normal Gmail password) |
| Odoo Developer Mode | Required to access the Technical menu |
Step 1 — Enable 2-Step Verification on Gmail
- Go to myaccount.google.com
- Security → 2-Step Verification
- Click Get started and complete the setup
Skip to Step 2 if 2-Step Verification is already on
Step 2 — Create an App Password
- Go to myaccount.google.com
- Security → 2-Step Verification → scroll down to App passwords
- App name → type
Odoo SMTP(any name works) - Click Create
- Save the 16-character token — it is shown only once
Example App Password:
abcd efgh ijkl mnop
(spaces can be removed when entering in Odoo)
Google Workspace: If App Passwords are disabled by admin → Admin Console → Security → Less secure apps → enable for users
Step 3 — Enable Developer Mode in Odoo
Settings → (scroll to bottom) → Activate the developer mode
Or append ?debug=1 to any Odoo URL.
Step 4 — Enable Custom Email Servers
Settings → General Settings → Discuss
☑ Use Custom Email Servers
→ Save
Step 5 — Add Outgoing Mail Server
Path: Settings → Technical → Email → Outgoing Mail Servers → New
| Field | Value for Gmail |
|---|---|
| Name | Gmail SMTP |
| SMTP Server | smtp.gmail.com |
| SMTP Port | 587 |
| Connection Security | STARTTLS |
| Username | Full Gmail address e.g. [email protected] |
| Password | 16-character App Password |
| Priority | 10 (default) |
→ Click Save
→ Click Test Connection
- ✅
Connection Test Succeeded!= configured correctly - ❌ Error → see Troubleshooting below
Step 6 — Set Default From Address (Recommended)
Settings → General Settings → Discuss
Default From Email: [email protected]
→ Save
Step 7 — DNS Records to Prevent Spam
Required if sending from a custom domain:
# SPF
TXT @ "v=spf1 include:_spf.google.com include:_spf.odoo.com mx ~all"
# DKIM — get key from Google Admin Console → Gmail → Authenticate email
TXT google._domainkey "v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY"
# DMARC
TXT _dmarc "v=DMARC1; p=quarantine; rua=mailto:[email protected]"Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Authentication failed | Using Gmail login password | Must use App Password |
No App passwords option | 2-Step Verification not enabled | Enable 2FA first |
| App Password option missing | Google Workspace admin disabled it | Ask admin to allow App Passwords |
Connection refused on port 587 | Firewall blocking | Try port 465 + SSL/TLS |
| Emails land in spam | SPF/DKIM not configured | Add DNS records |
| Wrong sender name | Default From not set | Set Default From Address |
| Emails stuck in queue | Scheduled action stopped | Check Email Queue Manager in Scheduled Actions |
Check Sent Emails
Settings → Technical → Email → Emails
Filter by status: Sent / In Queue / Exception
Quick Reference
1. Gmail: Enable 2FA → Create App Password (16 chars)
2. Odoo: Enable Developer Mode
3. Odoo: Settings → General Settings → Discuss → ☑ Use Custom Email Servers
4. Odoo: Settings → Technical → Email → Outgoing Mail Servers → New
SMTP: smtp.gmail.com | Port: 587 | STARTTLS
Username: [email protected] | Password: [App Password]
5. Test Connection → ✅
6. Set SPF/DKIM DNS records
Related
- Odoo Email Configuration — Full overview: SMTP, IMAP, Alias, DNS
- Odoo General Settings — Custom Email Servers toggle, Default From
- Odoo Helpdesk — Email-to-ticket via alias
- Odoo CRM — Email-to-lead via alias