การจัดการชื่อแทน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
อีเมลแทนสำหรับส่งในนามแสดงถึงอีเมลที่บัญชีใช้ส่งอีเมลได้
แต่ละบัญชีจะมีนามแฝงอย่างน้อย 1 รายการเสมอเพื่อแสดงถึง
อีเมลหลักของบัญชี
ชื่อแทนสำหรับส่งในชื่อจะสอดคล้องกับฟีเจอร์"ส่งอีเมลในชื่อ" ใน
อินเทอร์เฟซบนเว็บ
นอกจากนี้ยังใช้นามแฝงเพื่อจัดการลายเซ็นสำหรับบัญชีด้วย คุณต้องมีความเข้าใจพื้นฐาน
เกี่ยวกับนามแฝงสำหรับส่งอีเมลในชื่อจึงจะเปลี่ยนลายเซ็นอีเมลได้
วิดีโอด้านบนแสดงวิธีวนซ้ำผ่านอีเมลแทนสำหรับส่งเป็นและแก้ไขลายเซ็นสำหรับอีเมลหลักของผู้ใช้
ดูข้อมูลเกี่ยวกับวิธี
สร้าง
แสดง
รับ
อัปเดต
หรือลบนามแฝง
ได้ที่
SendAs
ข้อมูลอ้างอิง
การสร้างและยืนยันชื่อแทน
คุณต้องสร้าง
ชื่อแทนก่อนใช้งาน ในบางกรณี ผู้ใช้ต้องยืนยันการเป็นเจ้าของ
อีเมลแทนด้วย
หาก Gmail กำหนดให้ผู้ใช้ต้องยืนยันชื่อแทน ระบบจะแสดงชื่อแทนพร้อม
สถานะ pending
ระบบจะส่งข้อความยืนยันไปยัง
อีเมลปลายทางโดยอัตโนมัติ เจ้าของอีเมลต้องทำการยืนยันให้เสร็จสมบูรณ์ก่อนจึงจะใช้อีเมลได้
นามแฝงที่ไม่ต้องมีการยืนยันจะมีสถานะการยืนยันเป็น accepted
ใช้วิธีการ verify เพื่อ
ส่งคำขอยืนยันอีกครั้งหากจำเป็น
การตั้งค่า SMTP
นามแฝงสำหรับที่อยู่ภายนอกควรส่งอีเมลผ่าน SMTP ระยะไกล
Mail Sending Agent (MSA) หากต้องการกำหนดค่า MSA ของ SMTP สำหรับนามแฝง ให้ใช้ฟิลด์ smtpMsa
เพื่อระบุรายละเอียดการเชื่อมต่อ
การจัดการลายเซ็น
นอกจากนี้ คุณยังกำหนดค่าลายเซ็นอีเมลสำหรับแต่ละนามแฝงได้ด้วย เช่น หากต้องการตั้งค่าลายเซ็นสำหรับอีเมลหลักของผู้ใช้ ให้ทำดังนี้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-01 UTC
[null,null,["อัปเดตล่าสุด 2025-08-01 UTC"],[],[],null,["# Managing Aliases\n\nSend-as aliases represent the email addresses an account can\nsend mail from. Each account always has at least one alias to represent the\nprimary email address of the account.\n\nSend-as aliases correspond to the\n[\"Send mail as\" feature](https://support.google.com/mail/answer/22370) in the\nweb interface.\n\nAliases are also used to manage signatures for an account. Basic understanding\nof send-as aliases are required for you to be able to change email signatures.\nThe above video shows you how to loop through send-as aliases and modify the\nsignature for a user's primary email address.\n\nFor information about how to\n[create](/workspace/gmail/api/v1/reference/users/settings/sendAs/create),\n[list](/workspace/gmail/api/v1/reference/users/settings/sendAs/list),\n[get](/workspace/gmail/api/v1/reference/users/settings/sendAs/get),\n[update](/workspace/gmail/api/v1/reference/users/settings/sendAs/update),\nor [delete](/workspace/gmail/api/v1/reference/users/settings/sendAs/delete) aliases,\nsee the\n[`SendAs` reference](/workspace/gmail/api/reference/rest/v1/users.settings.sendAs).\n\nCreating and verifying aliases\n------------------------------\n\nYou must [create](/workspace/gmail/api/v1/reference/users/settings/sendAs/create)\naliases prior to use. In some cases, users must also verify ownership of the\nalias.\n\nIf Gmail requires user verification for an alias, the alias is returned with the\nstatus `pending`. A verification message is automatically sent to the\ntarget email address. The owner of the email address must complete the verification\nprocess before it can be used.\n\nAliases that do not require verification have a verification status of `accepted`.\n\nUse the [verify](/workspace/gmail/api/v1/reference/users/settings/sendAs/verify) method to\nresend the verification request if needed.\n\n### SMTP settings\n\nAliases for external addresses should send mail through a remote SMTP\nmail sending agent (MSA). To configure the SMTP MSA for an alias, use\nthe `smtpMsa` field to provide the connection details.\n\nManaging signatures\n-------------------\n\nYou may also configure email signatures for each alias. For example, to set the\nsignature for the user's primary address: \n\n### Java\n\ngmail/snippets/src/main/java/UpdateSignature.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/gmail/snippets/src/main/java/UpdateSignature.java) \n\n```java\nimport com.google.api.client.googleapis.json.GoogleJsonError;\nimport com.google.api.client.googleapis.json.GoogleJsonResponseException;\nimport com.google.api.client.http.HttpRequestInitializer;\nimport com.google.api.client.http.javanet.NetHttpTransport;\nimport com.google.api.client.json.gson.GsonFactory;\nimport com.google.api.services.gmail.Gmail;\nimport com.google.api.services.gmail.GmailScopes;\nimport com.google.api.services.gmail.model.ListSendAsResponse;\nimport com.google.api.services.gmail.model.SendAs;\nimport com.google.auth.http.HttpCredentialsAdapter;\nimport com.google.auth.oauth2.GoogleCredentials;\nimport java.io.IOException;\n\n/* Class to demonstrate the use of Gmail Update Signature API */\npublic class UpdateSignature {\n /**\n * Update the gmail signature.\n *\n * @return the updated signature id , {@code null} otherwise.\n * @throws IOException - if service account credentials file not found.\n */\n public static String updateGmailSignature() throws IOException {\n /* Load pre-authorized user credentials from the environment.\n TODO(developer) - See https://developers.google.com/identity for\n guides on implementing OAuth2 for your application. */\n GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()\n .createScoped(GmailScopes.GMAIL_SETTINGS_BASIC);\n HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);\n\n // Create the gmail API client\n Gmail service = new Gmail.Builder(new NetHttpTransport(),\n GsonFactory.getDefaultInstance(),\n requestInitializer)\n .setApplicationName(\"Gmail samples\")\n .build();\n\n try {\n SendAs primaryAlias = null;\n ListSendAsResponse aliases = service.users().settings().sendAs().list(\"me\").execute();\n for (SendAs alias : aliases.getSendAs()) {\n if (alias.getIsPrimary()) {\n primaryAlias = alias;\n break;\n }\n }\n // Updating a new signature\n SendAs aliasSettings = new SendAs().setSignature(\"Automated Signature\");\n SendAs result = service.users().settings().sendAs().patch(\n \"me\",\n primaryAlias.getSendAsEmail(),\n aliasSettings)\n .execute();\n //Prints the updated signature\n System.out.println(\"Updated signature - \" + result.getSignature());\n return result.getSignature();\n } catch (GoogleJsonResponseException e) {\n // TODO(developer) - handle error appropriately\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 403) {\n System.err.println(\"Unable to update signature: \" + e.getDetails());\n } else {\n throw e;\n }\n }\n return null;\n }\n}\n```\n\n### Python\n\ngmail/snippet/settings snippets/update_signature.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/gmail/snippet/settings snippets/update_signature.py) \n\n```python\nimport google.auth\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\n\ndef update_signature():\n \"\"\"Create and update signature in gmail.\n Returns:Draft object, including updated signature.\n\n Load pre-authorized user credentials from the environment.\n TODO(developer) - See https://developers.google.com/identity\n for guides on implementing OAuth2 for the application.\n \"\"\"\n creds, _ = google.auth.default()\n\n try:\n # create gmail api client\n service = build(\"gmail\", \"v1\", credentials=creds)\n\n primary_alias = None\n\n # pylint: disable=E1101\n aliases = service.users().settings().sendAs().list(userId=\"me\").execute()\n for alias in aliases.get(\"sendAs\"):\n if alias.get(\"isPrimary\"):\n primary_alias = alias\n break\n\n send_as_configuration = {\n \"displayName\": primary_alias.get(\"sendAsEmail\"),\n \"signature\": \"Automated Signature\",\n }\n\n # pylint: disable=E1101\n result = (\n service.users()\n .settings()\n .sendAs()\n .patch(\n userId=\"me\",\n sendAsEmail=primary_alias.get(\"sendAsEmail\"),\n body=send_as_configuration,\n )\n .execute()\n )\n print(f'Updated signature for: {result.get(\"displayName\")}')\n\n except HttpError as error:\n print(f\"An error occurred: {error}\")\n result = None\n\n return result.get(\"signature\")\n\n\nif __name__ == \"__main__\":\n update_signature()\n```"]]