{"thread":{"id":"63393","subject":"[PATCH 0/3] Improve checks for valid_fqdn in send-email and update documentation","startedAt":"2025-05-04T13:58:33Z","lastAt":"2025-05-13T12:28:51Z","messageCount":68,"participants":["Aditya Garg","Kristoffer Haugsbakk","Junio C Hamano","Julian Swagemakers","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"517189","messageId":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":null,"subject":"[PATCH 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-04T13:54:55Z","receivedAt":"2025-05-04T13:58:33Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |   4 ++\n git-send-email.perl               |   3 +-\n 3 files changed, 99 insertions(+), 14 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517190","messageId":"PN3PR01MB95975D45B072101812714C72B88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-04T13:54:56Z","receivedAt":"2025-05-04T13:58:36Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain was coming out\nto be \"MacBook..\" and was being considered as valid. As a result\nthe script was failing. The debug logs with the failed script are\nbelow:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x5db4351225f8)<<< 220 BMXPR01CA0083.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:06:30 +0000 [08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:35.781Z 08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:40.828Z 08DD842467C8274D]\nUnable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.office365.com encryption=tls hello=MacBook.. port=587 at ../git-send-email.perl line 1727.\n\nWith this patch, it was fixed and was being considered as an invalid\ndomain. Logs after this patch:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 PN4P287CA0064.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:08:13 +0000 [08DD84B323498C1A]\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP=GLOB(0x58c8af71e930)>>> STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 2.0.0 SMTP server ready\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> AUTH XOAUTH2 (OAuth2 access token removed for security)\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 235 2.7.0 Authentication successful\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..4c143e24bf 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,8 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z0-9-]{1,63})+$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517191","messageId":"PN3PR01MB95977D3ACA96D04442960136B88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-04T13:54:57Z","receivedAt":"2025-05-04T13:58:38Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit does the following changes to the send email doc:\n\n1. Added examples to use OAuth2.0 with Gmail and Outlook.\n2. Improved examples to send patches using git send-email\n3. Added links of credential helpers for Gmail and Outlook\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n 1 file changed, 93 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..ada883289a 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use 'git send-email' to send your patches through the Gmail SMTP server,\n+edit '~/.gitconfig' to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,17 +528,97 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n-Once your commits are ready to be sent to the mailing list, run the\n-following commands:\n+You can also use OAuth2.0 authentication with Gmail. For that edit ~/.gitconfig\n+and add `smtpAuth = OAUTHBEARER` to your account settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, we have to use OAuth2.0 authentication for Outlook.\n+\n+Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n+SMTP server with 'git send-email':\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n+The following examples can be used to have a basic idea on how to send patches\n+to a mailing list:\n+\n+If you want to send a single patch, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~1\n+\n+You can also add `--annotate` to edit the patches before sending:\n+\n+\t$ git send-email --annotate --to=\"mailinglist@example.org\" HEAD~1\n+\n+Multiple patches can also be sent. For example, if you want to send the last 3\n+commits as patches, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~3\n+\n+You can also add a cover letter. It is useful especially in case of multiple\n+patches. Note the use of `--annotate` here since we have to edit the cover letter\n+before sending it:\n+\n+\t$ git send-email --annotate --cover-letter --to=\"mailinglist@example.org\" HEAD~3\n+\n+Versions of a patch series can also be specified. For example to send a version 2:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" -v2 HEAD~1\n+\n+You can also specify custom subject prefixes. For example, to have '[PATCH RESEND]'\n+as a prefix, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --subject-prefix='PATCH RESEND' HEAD~1\n+\n+You can also Cc someone like this:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --cc=\"someone@example.com HEAD~1\n+\n+Multiple `--to` can also be specified:\n+\n+\t$ git send-email --to=\"list1@example.org\" --to=\"list2@example.com HEAD~1\n+\n+Similarly you can specify multiple `--cc` as well.\n \n-\t$ git format-patch --cover-letter -M origin/master -o outgoing/\n-\t$ edit outgoing/0000-*\n-\t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers with OAuth2.0 support\n+for Gmail and Outlook are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517192","messageId":"PN3PR01MB95976CCB3C645470DDB73C0BB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-04T13:54:58Z","receivedAt":"2025-05-04T13:58:40Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..62718a0422 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517193","messageId":"a2ceea8b-8354-4316-88ec-54111fb98d69@app.fastmail.com","threadId":"63393","inReplyTo":"PN3PR01MB95975D45B072101812714C72B88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH 1/3] send-mail: improve checks for valid_fqdn","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-05-04T14:22:32Z","receivedAt":"2025-05-04T14:22:54Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sun, May 4, 2025, at 15:54, Aditya Garg wrote:\n> [1]: https://datatracker.ietf.org/doc/html/rfc1035\n> Signed-off-by: Aditya Garg <gargaditya08@live.com>\n\nFinding the s-o-b here works fine since only 25% of the trailer block\nmust be valid trailers, but it’s probably best in general to separate\nfootnotes and the trailer block with a blank line.\n\n> ---\n>  git-send-email.perl | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 4215f8f7e9..4c143e24bf 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1359,7 +1359,8 @@ sub process_address_list {\n>\n>  sub valid_fqdn {\n>  \tmy $domain = shift;\n> -\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n> && $domain =~ /\\./;\n> +\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n> +\t\t&& $domain  =~\n> /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z0-9-]{1,63})+$/;\n>  }\n>\n>  sub maildomain_net {\n> --\n> 2.49.0\n"},{"id":"517194","messageId":"PN3PR01MB95976EC68E23CDB5A77AE741B88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"a2ceea8b-8354-4316-88ec-54111fb98d69@app.fastmail.com","subject":"Re: [PATCH 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-04T15:26:27Z","receivedAt":"2025-05-04T15:26:32Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 4 May 2025, at 7:53 PM, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:\n> \n> ﻿On Sun, May 4, 2025, at 15:54, Aditya Garg wrote:\n>> [1]: https://datatracker.ietf.org/doc/html/rfc1035\n>> Signed-off-by: Aditya Garg <gargaditya08@live.com>\n> \n> Finding the s-o-b here works fine since only 25% of the trailer block\n> must be valid trailers, but it’s probably best in general to separate\n> footnotes and the trailer block with a blank line.\n\nSure. I'll wait for some more reviews and send a v2 tomorrow.\n"},{"id":"517195","messageId":"96413038-8b21-44f7-b426-ea9d61b90cc0@app.fastmail.com","threadId":"63393","inReplyTo":"PN3PR01MB95976EC68E23CDB5A77AE741B88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH 1/3] send-mail: improve checks for valid_fqdn","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-05-04T16:05:05Z","receivedAt":"2025-05-04T16:05:29Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Sun, May 4, 2025, at 17:26, Aditya Garg wrote:\n>> On 4 May 2025, at 7:53 PM, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:\n>>\n>> ﻿On Sun, May 4, 2025, at 15:54, Aditya Garg wrote:\n>>> [1]: https://datatracker.ietf.org/doc/html/rfc1035\n>>> Signed-off-by: Aditya Garg <gargaditya08@live.com>\n>>\n>> Finding the s-o-b here works fine since only 25% of the trailer block\n>> must be valid trailers, but it’s probably best in general to separate\n>> footnotes and the trailer block with a blank line.\n>\n> Sure. I'll wait for some more reviews and send a v2 tomorrow.\n\nIf there are no other comments then that’s just a nitpick. :) Maybe a v2\nwon’t be needed.\n"},{"id":"517200","messageId":"PN3PR01MB9597827866A582654661102CB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v2 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T06:16:21Z","receivedAt":"2025-05-05T06:19:06Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nv2: - Improve grammar and add missing \"\" in second patch.\n    - Separate footnotes and the trailer block with a blank line in the first patch.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |   4 ++\n git-send-email.perl               |   3 +-\n 3 files changed, 99 insertions(+), 14 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517201","messageId":"PN3PR01MB95976908158F1091EC482088B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597827866A582654661102CB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v2 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T06:16:22Z","receivedAt":"2025-05-05T06:19:10Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain was coming out\nto be \"MacBook..\" and was being considered as valid. As a result\nthe script was failing. The debug logs with the failed script are\nbelow:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x5db4351225f8)<<< 220 BMXPR01CA0083.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:06:30 +0000 [08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:35.781Z 08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:40.828Z 08DD842467C8274D]\nUnable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.office365.com encryption=tls hello=MacBook.. port=587 at ../git-send-email.perl line 1727.\n\nWith this patch, it was fixed and was being considered as an invalid\ndomain. Logs after this patch:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 PN4P287CA0064.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:08:13 +0000 [08DD84B323498C1A]\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP=GLOB(0x58c8af71e930)>>> STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 2.0.0 SMTP server ready\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> AUTH XOAUTH2 (OAuth2 access token removed for security)\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 235 2.7.0 Authentication successful\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..4c143e24bf 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,8 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z0-9-]{1,63})+$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517202","messageId":"PN3PR01MB9597E545331A9BBF088329EBB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597827866A582654661102CB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v2 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T06:16:23Z","receivedAt":"2025-05-05T06:19:12Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit does the following changes to the send email doc:\n\n1. Added examples to use OAuth2.0 with Gmail and Outlook.\n2. Improved examples to send patches using git send-email\n3. Added links of credential helpers for Gmail and Outlook\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n 1 file changed, 93 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..af29e61299 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP Server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use 'git send-email' to send your patches through the Gmail SMTP server,\n+edit '~/.gitconfig' to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,17 +528,97 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n-Once your commits are ready to be sent to the mailing list, run the\n-following commands:\n+You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n+`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP Server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, OAuth2.0 authentication must be used for Outlook.\n+\n+Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n+SMTP server with 'git send-email':\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n+The following examples can be used to have a basic idea on how to send patches\n+to a mailing list:\n+\n+If you want to send a single patch, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~1\n+\n+You can also add `--annotate` to edit the patches before sending:\n+\n+\t$ git send-email --annotate --to=\"mailinglist@example.org\" HEAD~1\n+\n+Multiple patches can also be sent. For example, if you want to send the last 3\n+commits as patches, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~3\n+\n+You can also add a cover letter. It is useful especially in case of multiple\n+patches. Note the use of `--annotate` here since we have to edit the cover letter\n+before sending it:\n+\n+\t$ git send-email --annotate --cover-letter --to=\"mailinglist@example.org\" HEAD~3\n+\n+Versions of a patch series can also be specified. For example to send a version 2:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" -v2 HEAD~1\n+\n+You can also specify custom subject prefixes. For example, to have '[PATCH RESEND]'\n+as a prefix, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --subject-prefix='PATCH RESEND' HEAD~1\n+\n+You can also Cc someone like this:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --cc=\"someone@example.com\" HEAD~1\n+\n+Multiple `--to` can also be specified:\n+\n+\t$ git send-email --to=\"list1@example.org\" --to=\"list2@example.com\" HEAD~1\n+\n+Similarly you can specify multiple `--cc` as well.\n \n-\t$ git format-patch --cover-letter -M origin/master -o outgoing/\n-\t$ edit outgoing/0000-*\n-\t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers for Gmail and Outlook\n+are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517203","messageId":"PN3PR01MB95972F543FFF12319D17BB94B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597827866A582654661102CB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v2 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T06:16:24Z","receivedAt":"2025-05-05T06:19:14Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..62718a0422 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-outlook-and-gmail[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517255","messageId":"PN3PR01MB9597BD33DB2C4F3BE9E5F4C6B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v3 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T15:23:02Z","receivedAt":"2025-05-05T15:26:14Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nP.S. I have used `git-credential-outlook` linked in the second and third\npatch for this email!\n\nv2: - Improve grammar and add missing \"\" in second patch.\n    - Separate footnotes and the trailer block with a blank line in the first patch.\n\nv3: - Change link for email helpers since old one was too long.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |   4 ++\n git-send-email.perl               |   3 +-\n 3 files changed, 99 insertions(+), 14 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517256","messageId":"PN3PR01MB959784F880EDC6E30BF46F23B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597BD33DB2C4F3BE9E5F4C6B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v3 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T15:23:05Z","receivedAt":"2025-05-05T15:26:15Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..b49923db02 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517257","messageId":"PN3PR01MB95971B8A202ADEA412010B35B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597BD33DB2C4F3BE9E5F4C6B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T15:23:03Z","receivedAt":"2025-05-05T15:26:19Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain was coming out\nto be \"MacBook..\" and was being considered as valid. As a result\nthe script was failing. The debug logs with the failed script are\nbelow:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x5db4351225f8)<<< 220 BMXPR01CA0083.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:06:30 +0000 [08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:35.781Z 08DD842467C8274D]\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name [BMXPR01CA0083.INDPRD01.PROD.OUTLOOK.COM 2025-04-26T18:06:40.828Z 08DD842467C8274D]\nUnable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.office365.com encryption=tls hello=MacBook.. port=587 at ../git-send-email.perl line 1727.\n\nWith this patch, it was fixed and was being considered as an invalid\ndomain. Logs after this patch:\n\nNet::SMTP>>> Net::SMTP(3.15)\nNet::SMTP>>>   Net::Cmd(3.15)\nNet::SMTP>>>     Exporter(5.77)\nNet::SMTP>>>   IO::Socket::IP(0.4101)\nNet::SMTP>>>     IO::Socket(1.52)\nNet::SMTP>>>       IO::Handle(1.52)\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 PN4P287CA0064.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 26 Apr 2025 18:08:13 +0000 [08DD84B323498C1A]\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP=GLOB(0x58c8af71e930)>>> STARTTLS\nNet::SMTP=GLOB(0x58c8af71e930)<<< 220 2.0.0 SMTP server ready\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello [2401:4900:a052:31f0:9beb:e613:56e8:f897]\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-SIZE 157286400\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-PIPELINING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-DSN\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-ENHANCEDSTATUSCODES\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-AUTH LOGIN XOAUTH2\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-8BITMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-BINARYMIME\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250-CHUNKING\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 250 SMTPUTF8\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)>>> AUTH XOAUTH2 (OAuth2 access token removed for security)\nNet::SMTP::_SSL=GLOB(0x58c8af71e930)<<< 235 2.7.0 Authentication successful\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..4c143e24bf 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,8 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.[A-Za-z0-9-]{1,63})+$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517258","messageId":"PN3PR01MB95971776178BED3516DA03DCB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597BD33DB2C4F3BE9E5F4C6B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v3 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T15:23:04Z","receivedAt":"2025-05-05T15:26:22Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit does the following changes to the send email doc:\n\n1. Added examples to use OAuth2.0 with Gmail and Outlook.\n2. Improved examples to send patches using git send-email\n3. Added links of credential helpers for Gmail and Outlook\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 106 ++++++++++++++++++++++++++----\n 1 file changed, 93 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..f30f573209 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP Server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use 'git send-email' to send your patches through the Gmail SMTP server,\n+edit '~/.gitconfig' to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,17 +528,97 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n-Once your commits are ready to be sent to the mailing list, run the\n-following commands:\n+You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n+`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP Server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, OAuth2.0 authentication must be used for Outlook.\n+\n+Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n+SMTP server with 'git send-email':\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n+The following examples can be used to have a basic idea on how to send patches\n+to a mailing list:\n+\n+If you want to send a single patch, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~1\n+\n+You can also add `--annotate` to edit the patches before sending:\n+\n+\t$ git send-email --annotate --to=\"mailinglist@example.org\" HEAD~1\n+\n+Multiple patches can also be sent. For example, if you want to send the last 3\n+commits as patches, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" HEAD~3\n+\n+You can also add a cover letter. It is useful especially in case of multiple\n+patches. Note the use of `--annotate` here since we have to edit the cover letter\n+before sending it:\n+\n+\t$ git send-email --annotate --cover-letter --to=\"mailinglist@example.org\" HEAD~3\n+\n+Versions of a patch series can also be specified. For example to send a version 2:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" -v2 HEAD~1\n+\n+You can also specify custom subject prefixes. For example, to have '[PATCH RESEND]'\n+as a prefix, run:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --subject-prefix='PATCH RESEND' HEAD~1\n+\n+You can also Cc someone like this:\n+\n+\t$ git send-email --to=\"mailinglist@example.org\" --cc=\"someone@example.com\" HEAD~1\n+\n+Multiple `--to` can also be specified:\n+\n+\t$ git send-email --to=\"list1@example.org\" --to=\"list2@example.com\" HEAD~1\n+\n+Similarly you can specify multiple `--cc` as well.\n \n-\t$ git format-patch --cover-letter -M origin/master -o outgoing/\n-\t$ edit outgoing/0000-*\n-\t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers for Gmail and Outlook\n+are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517272","messageId":"xmqqv7qeooed.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597E545331A9BBF088329EBB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v2 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-05T19:20:26Z","receivedAt":"2025-05-05T19:20:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> This commit does the following changes to the send email doc:\n>\n> 1. Added examples to use OAuth2.0 with Gmail and Outlook.\n> 2. Improved examples to send patches using git send-email\n> 3. Added links of credential helpers for Gmail and Outlook\n\nThe usual way to compose a log message of this project is to\n\n - Give an observation on how the current system works in the present\n   tense (so no need to say \"Currently X is Y\", just \"X is Y\"), and\n   discuss what you perceive as a problem in it.\n\n - Propose a solution (optional---often, problem description\n   trivially leads to an obvious solution in reader's minds).\n\n - Give commands to the codebase to \"become like so\".\n\nin this order.  Don't throw a bulleted list at readers without\npreparing them by explaining what problem you are solving and why\nsuch a solution is needed.\n\n> +SENDING PATCHES\n> +---------------\n> +The following examples can be used to have a basic idea on how to send patches\n> +to a mailing list:\n> +\n> +If you want to send a single patch, run:\n> +\n> +\t$ git send-email --to=\"mailinglist@example.org\" HEAD~1\n> ...\n> -\t$ git format-patch --cover-letter -M origin/master -o outgoing/\n> -\t$ edit outgoing/0000-*\n> -\t$ git send-email outgoing/*\n\nAll good intentions to improve the documentation, but loss of these\nlines is very much lamentable, especially the fact that these\noriginal instructions were written to encourage to run format-patch\nand send-email as separate steps, with proofreading and final\ncopy-editing step in between.\n\nIt means the author has a chance to spend more time and care to help\nrecipients read their patches more smoothly with fewer typoes and\nimproved explanations.\n\nRunning \"git send-email\" with the revision range to run the \"git\nformat-patch\" command is often an anti-pattern, especially for\nunexperienced people who are still learning from the examples in the\ndocumentation.  Please do not unnecessarily promote the use of it.\n\nThanks.\n\n"},{"id":"517273","messageId":"PN3PR01MB95972A228D52741453DE824AB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqv7qeooed.fsf@gitster.g","subject":"Re: [PATCH v2 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-05T19:30:26Z","receivedAt":"2025-05-05T19:30:32Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 6 May 2025, at 12:50 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>> This commit does the following changes to the send email doc:\n>> \n>> 1. Added examples to use OAuth2.0 with Gmail and Outlook.\n>> 2. Improved examples to send patches using git send-email\n>> 3. Added links of credential helpers for Gmail and Outlook\n> \n> The usual way to compose a log message of this project is to\n> \n> - Give an observation on how the current system works in the present\n>   tense (so no need to say \"Currently X is Y\", just \"X is Y\"), and\n>   discuss what you perceive as a problem in it.\n> \n> - Propose a solution (optional---often, problem description\n>   trivially leads to an obvious solution in reader's minds).\n> \n> - Give commands to the codebase to \"become like so\".\n> \n> in this order.  Don't throw a bulleted list at readers without\n> preparing them by explaining what problem you are solving and why\n> such a solution is needed.\n> \n>> +SENDING PATCHES\n>> +---------------\n>> +The following examples can be used to have a basic idea on how to send patches\n>> +to a mailing list:\n>> +\n>> +If you want to send a single patch, run:\n>> +\n>> +    $ git send-email --to=\"mailinglist@example.org\" HEAD~1\n>> ...\n>> -    $ git format-patch --cover-letter -M origin/master -o outgoing/\n>> -    $ edit outgoing/0000-*\n>> -    $ git send-email outgoing/*\n> \n> All good intentions to improve the documentation, but loss of these\n> lines is very much lamentable, especially the fact that these\n> original instructions were written to encourage to run format-patch\n> and send-email as separate steps, with proofreading and final\n> copy-editing step in between.\n> \n> It means the author has a chance to spend more time and care to help\n> recipients read their patches more smoothly with fewer typoes and\n> improved explanations.\n> \n> Running \"git send-email\" with the revision range to run the \"git\n> format-patch\" command is often an anti-pattern, especially for\n> unexperienced people who are still learning from the examples in the\n> documentation.  Please do not unnecessarily promote the use of it.\n\nFair. I'll revert that section. You want me to revert the OAuth2.0 examples\nas well?"},{"id":"517282","messageId":"xmqqplgmlisy.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB95971B8A202ADEA412010B35B88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-05T23:49:33Z","receivedAt":"2025-05-05T23:49:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> Due to current implementation, I was not able to send emails from\n> Ubuntu.\n\nIt may be that send-email did not complain, but I have a suspicion\nthat it the above is only half truth.  We do have an ugly last-ditch\nfallback to claim that we are localhost.localdomain, instead of\nusing a misconfigured maildomain name that servers would not like,\nbut that name is a meaningless name; from the point of view of the\nserver, if everybody uses that name, the name loses the meaning as\nan identifier.\n\nIt is more like due to misconfiguration you couldn't send e-mails,\nand by tightening the condition to tell an invalid maildomain name\nand have the misconfigured maildomain name that is invalid replaced\nwith \"localhost.localdomain\" fallback, you managed to send things\nout.\n\nThe real fix for individual users may probably be to see how\nmaildomain_net() and/or maildomain_mta() gives you a bogus\n\"Macbook..\" and fix _that_.  Until that gets fixed, trying to use\n\"localhost.localdomain\" fallback might be a good workaround, but\nthat is a workaround, not a real solution, isn't it?\n\nWhen using this fallback, we are at server's mercy; if a server\nchecks the name you give it against your IP address, for example,\nthe \"localhost.localdomain\" fallback may be rejected and you would\nneed to figure out the real maildomain name the server wants you to\nidentify as.  What I am worried about this patch the most is if it\nis tightening valid_fqdn too much to make a good maildomain name\nthat real users are currently using to cause them to instead use the\n\"localhost.localdomain\" fallback, and their SMTP servers are not\nas lenient as your case and start rejecting their requests.\n\nWith a cursory read of this patch, I think basic \"at most 63 Alnum\nor dash\" DNS label defined in the ASCII-only era may be sufficient\nfor 99% of the users, so I am not too worried by this particular\nchange (I do not think anybody uses those UUCP!style!addresses\nanymore these days), but this patch is an example why we always\nwant to be careful not to introduce unintended regressions.\n\n> Upon debugging, I found that the SMTP domain was coming out\n> to be \"MacBook..\" and was being considered as valid.\n\n\"as valid.\" -> \"as valid, which prevented the fallback\nlocalhost.localdomain from being used.\"\n\n> As a result\n> the script was failing. The debug logs with the failed script are\n> below:\n\nDon't give overly long and irrelevant details.  Say something like\n\n\tThe SMTP exchange started like this:\n\n\t<<< 220 ...outlook.office365.com Microsoft ...\n\t>>> EHLO MacBook..\n\t<<< 501 5.5.4 Invalid domain name ...\n\n\tNotice that an invalid domain name \"MacBook..\" is sent by\n\tgit-send-email.  We have a fallback code that checks output\n\tfrom Net::Domain::domainname() or asking domain method of an\n\tNet::SMTP instance to detect a misconfigured hostname and\n\treplace it with fallback \"localhost.localdomain\", but\n\tthe valid_fqdn apparently is failing to say \"MacBook..\" is\n\tnot a valid_fqdn.\n\n\tWith this patch, the rule used in valid_fqdn is tightened,\n\tthe beginning part of the SMTP exchange looked like this:\n\n\t<<< 220 ...outlook.office365.com Microsoft ...\n\t>>> EHLO localhost.localdomain\n\t<<< 250-250-PN4P287CA0064.outlook.office365.com Hello ...\n\t<<< 250 ...\n\n\tand the server I was using to test this patch was happy with\n\tthe fallback \"localhost.localdomain\":\n\nperhaps?\n\nThanks.\n"},{"id":"517283","messageId":"xmqqldralil9.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB95971776178BED3516DA03DCB88E2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-05T23:54:10Z","receivedAt":"2025-05-05T23:54:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> +If you want to send a single patch, run:\n> +\n> +\t$ git send-email --to=\"mailinglist@example.org\" HEAD~1\n\nDidn't I already tell you not to encourage to run format-patch from\nsend-email all over the place?  Just prepare the mail files once,\nand feed them, perhaps\n\n    ... how to send patches to a mailing list from a set of patch\n    files you prepared with `git format-patch`.\n\n    If you want to send a single patch:\n\n\t$ git send-email --to=\"there\" 0001-fix-this.patch\n\n    Or more than one\n\n\t$ git send-email --to=\"there\" patches/000[1-4]*.patch\n\netc.\n\n> -\t$ git format-patch --cover-letter -M origin/master -o outgoing/\n> -\t$ edit outgoing/0000-*\n> -\t$ git send-email outgoing/*\n"},{"id":"517289","messageId":"PN3PR01MB9597EF61B4CC43595DE4341BB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqldralil9.fsf@gitster.g","subject":"Re: [PATCH v3 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T05:36:52Z","receivedAt":"2025-05-06T05:36:58Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 6 May 2025, at 5:24 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>> +If you want to send a single patch, run:\n>> +\n>> +    $ git send-email --to=\"mailinglist@example.org\" HEAD~1\n> \n> Didn't I already tell you not to encourage to run format-patch from\n> send-email all over the place?  Just prepare the mail files once,\n> and feed them, perhaps\n\nThis version was sent before your review ;)\n> \n>    ... how to send patches to a mailing list from a set of patch\n>    files you prepared with `git format-patch`.\n> \n>    If you want to send a single patch:\n> \n>    $ git send-email --to=\"there\" 0001-fix-this.patch\n> \n>    Or more than one\n> \n>    $ git send-email --to=\"there\" patches/000[1-4]*.patch\n> \n> etc.\n> \n>> -    $ git format-patch --cover-letter -M origin/master -o outgoing/\n>> -    $ edit outgoing/0000-*\n>> -    $ git send-email outgoing/*\n"},{"id":"517290","messageId":"PN3PR01MB9597B15F81AC6DDB35546C2CB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqplgmlisy.fsf@gitster.g","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T05:38:37Z","receivedAt":"2025-05-06T05:38:41Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 6 May 2025, at 5:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>> Due to current implementation, I was not able to send emails from\n>> Ubuntu.\n> \n> It may be that send-email did not complain, but I have a suspicion\n> that it the above is only half truth.  We do have an ugly last-ditch\n> fallback to claim that we are localhost.localdomain, instead of\n> using a misconfigured maildomain name that servers would not like,\n> but that name is a meaningless name; from the point of view of the\n> server, if everybody uses that name, the name loses the meaning as\n> an identifier.\n> \n> It is more like due to misconfiguration you couldn't send e-mails,\n> and by tightening the condition to tell an invalid maildomain name\n> and have the misconfigured maildomain name that is invalid replaced\n> with \"localhost.localdomain\" fallback, you managed to send things\n> out.\n> \n> The real fix for individual users may probably be to see how\n> maildomain_net() and/or maildomain_mta() gives you a bogus\n> \"Macbook..\" and fix _that_.  Until that gets fixed, trying to use\n> \"localhost.localdomain\" fallback might be a good workaround, but\n> that is a workaround, not a real solution, isn't it?\n\nI think I should dig deeper on how the domain name is being assigned.\n\nMaybe its time to fix another perl module after Authen::SASL?"},{"id":"517305","messageId":"PN3PR01MB9597ED4DA3E781A6EFC03B9CB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597B15F81AC6DDB35546C2CB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T09:35:05Z","receivedAt":"2025-05-06T09:35:10Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 6 May 2025, at 11:08 AM, Aditya Garg <gargaditya08@live.com> wrote:\n> \n> ﻿\n> \n>> On 6 May 2025, at 5:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> \n>> ﻿Aditya Garg <gargaditya08@live.com> writes:\n>> \n>>> Due to current implementation, I was not able to send emails from\n>>> Ubuntu.\n>> \n>> It may be that send-email did not complain, but I have a suspicion\n>> that it the above is only half truth.  We do have an ugly last-ditch\n>> fallback to claim that we are localhost.localdomain, instead of\n>> using a misconfigured maildomain name that servers would not like,\n>> but that name is a meaningless name; from the point of view of the\n>> server, if everybody uses that name, the name loses the meaning as\n>> an identifier.\n>> \n>> It is more like due to misconfiguration you couldn't send e-mails,\n>> and by tightening the condition to tell an invalid maildomain name\n>> and have the misconfigured maildomain name that is invalid replaced\n>> with \"localhost.localdomain\" fallback, you managed to send things\n>> out.\n>> \n>> The real fix for individual users may probably be to see how\n>> maildomain_net() and/or maildomain_mta() gives you a bogus\n>> \"Macbook..\" and fix _that_.  Until that gets fixed, trying to use\n>> \"localhost.localdomain\" fallback might be a good workaround, but\n>> that is a workaround, not a real solution, isn't it?\n> \n> I think I should dig deeper on how the domain name is being assigned.\n> \n> Maybe its time to fix another perl module after Authen::SASL?\n\nI've noticed bug reports regarding this in Net::Domain perl library.\nMost reports seem to be not addressed. Maybe its no longer maintained?\n\nI think we can add a minimal check to ensure that there are no two dots together.\nDoes that sound fair?"},{"id":"517363","messageId":"PN3PR01MB9597E09838320FF9F403D255B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597ED4DA3E781A6EFC03B9CB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T16:50:35Z","receivedAt":"2025-05-06T16:50:44Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\nOn 06/05/25 3:05 pm, Aditya Garg wrote:\n> \n> \n>> On 6 May 2025, at 11:08 AM, Aditya Garg <gargaditya08@live.com> wrote:\n>>\n>> ﻿\n>>\n>>> On 6 May 2025, at 5:19 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>\n>>> ﻿Aditya Garg <gargaditya08@live.com> writes:\n>>>\n>>>> Due to current implementation, I was not able to send emails from\n>>>> Ubuntu.\n>>>\n>>> It may be that send-email did not complain, but I have a suspicion\n>>> that it the above is only half truth.  We do have an ugly last-ditch\n>>> fallback to claim that we are localhost.localdomain, instead of\n>>> using a misconfigured maildomain name that servers would not like,\n>>> but that name is a meaningless name; from the point of view of the\n>>> server, if everybody uses that name, the name loses the meaning as\n>>> an identifier.\n>>>\n>>> It is more like due to misconfiguration you couldn't send e-mails,\n>>> and by tightening the condition to tell an invalid maildomain name\n>>> and have the misconfigured maildomain name that is invalid replaced\n>>> with \"localhost.localdomain\" fallback, you managed to send things\n>>> out.\n>>>\n>>> The real fix for individual users may probably be to see how\n>>> maildomain_net() and/or maildomain_mta() gives you a bogus\n>>> \"Macbook..\" and fix _that_.  Until that gets fixed, trying to use\n>>> \"localhost.localdomain\" fallback might be a good workaround, but\n>>> that is a workaround, not a real solution, isn't it?\n>>\n>> I think I should dig deeper on how the domain name is being assigned.\n>>\n>> Maybe its time to fix another perl module after Authen::SASL?\n> \n> I've noticed bug reports regarding this in Net::Domain perl library.\n> Most reports seem to be not addressed. Maybe its no longer maintained?\n> \n> I think we can add a minimal check to ensure that there are no two dots together.\n> Does that sound fair?\n\nI have opened a PR here to fix the Net::Domain library:\n\nhttps://github.com/steve-m-hay/perl-libnet/pull/47\n\n\nAlthough, this library is still seems quite unreliable. See:\n\n1. https://github.com/Perl/perl5/issues/17135\n2. https://github.com/glpi-project/glpi-agent/discussions/345\n\nI really doubt the maintainer still maintains this. I have added them to the Cc though.\n\nAs far as the script is concerned,\n\n- The script currently checks the presence of a period in the fqdn.\n- At the same time, the script does NOT check whether the fqdn starts or ends with a period.\n- Also, it does NOT check if 2 periods are together or not.\n\na fqdn without a dot at all gets accepted by my Outlook server, but the next 2 cases are a big\nno. I think adding checks for these cases should make sense, afterall no FQDN would have these\nthings.\n\n"},{"id":"517365","messageId":"xmqqecx1ll5e.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597ED4DA3E781A6EFC03B9CB8892@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-06T17:11:09Z","receivedAt":"2025-05-06T17:11:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> I think we can add a minimal check to ensure that there are no two dots together.\n> Does that sound fair?\n\nIs it a common misconfiguration in the first place that singling out\na name ending with double dots (which indeed is very likely that\nnobody should be relying on getting accepted by sensible SMTP\nservers, hence very safe tightening) is worth doing?  If MacBooks as\nshipped would by default claim to be \"MacBook..\" like your example\nhad (I do not know if that is the case, as I do not live in Apple\necosystem), it may give us a reason to special case the trailing\ndouble-dots, for example.\n\nI personally feel that \"run of at most 63 alnum or dash separated by\na single dot in between\" is easy enough to explain, so if I were\ndoing this change, I would just use the regexp used in posted patch\n[*] and if nobody complains, stop right there.  If we get any\ncomplaint, then I'd detect and reject the case where the string ends\nwith double-dots.\n\n[Footnote]\n\n * ... but I don't know if your use of negative lookaround\n   assersions is correct.  Shouldn't the \"a label cannot begin or\n   end with dash\" be applied not just to the first label but\n   consistently to all of the dot-separated labels?\n\n\n\n"},{"id":"517367","messageId":"PN3PR01MB959731081532150F5FE54875B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqecx1ll5e.fsf@gitster.g","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T17:23:44Z","receivedAt":"2025-05-06T17:23:53Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\nOn 06/05/25 10:41 pm, Junio C Hamano wrote:\n> Aditya Garg <gargaditya08@live.com> writes:\n> \n>> I think we can add a minimal check to ensure that there are no two dots together.\n>> Does that sound fair?\n> \n> Is it a common misconfiguration in the first place that singling out\n> a name ending with double dots (which indeed is very likely that\n> nobody should be relying on getting accepted by sensible SMTP\n> servers, hence very safe tightening) is worth doing?  If MacBooks as\n> shipped would by default claim to be \"MacBook..\" like your example\n> had (I do not know if that is the case, as I do not live in Apple\n> ecosystem), it may give us a reason to special case the trailing\n> double-dots, for example.\n\nIts not an Apple thing. I am not even using macOS at the first place\nwhen I tested this, I was on Ubuntu running on my Mac.\n\nIts a problem with Net::Domain. In systems without a domainname, and\nwithout a period in the hostname, Net::Domain will always output\n\"hostname..\". You probably should check your machine with smtp-debug?\nBtw, the output of `hostname -f` on these machines will be \"hostname\".\n\nNow gmail does not reject this, probably the reason it is unnoticed?\nSince Outlook support is new, such problems are being observed.\n\n\n> \n> I personally feel that \"run of at most 63 alnum or dash separated by\n> a single dot in between\" is easy enough to explain, so if I were\n> doing this change, I would just use the regexp used in posted patch\n> [*] and if nobody complains, stop right there.  If we get any\n> complaint, then I'd detect and reject the case where the string ends\n> with double-dots.\n\nThe regexp used in the original patch covers the double dots case as well.\nIts basically following the RFC guidelines, which a sensible SMTP server\nshould follow, and so must a user.\n\n> \n> [Footnote]\n> \n>  * ... but I don't know if your use of negative lookaround\n>    assersions is correct.  Shouldn't the \"a label cannot begin or\n>    end with dash\" be applied not just to the first label but\n>    consistently to all of the dot-separated labels?\n\nI think you are talking about this case:\n\nsomeone.-example.com\n\nNo, its not valid.a\n"},{"id":"517371","messageId":"PN3PR01MB9597CF56985502FBC32A8520B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB959731081532150F5FE54875B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-06T17:49:55Z","receivedAt":"2025-05-06T17:50:00Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 6 May 2025, at 10:53 PM, Aditya Garg <gargaditya08@live.com> wrote:\n> \n> ﻿\n> \n>> On 06/05/25 10:41 pm, Junio C Hamano wrote:\n>> Aditya Garg <gargaditya08@live.com> writes:\n>> \n>>> I think we can add a minimal check to ensure that there are no two dots together.\n>>> Does that sound fair?\n>> \n>> Is it a common misconfiguration in the first place that singling out\n>> a name ending with double dots (which indeed is very likely that\n>> nobody should be relying on getting accepted by sensible SMTP\n>> servers, hence very safe tightening) is worth doing?  If MacBooks as\n>> shipped would by default claim to be \"MacBook..\" like your example\n>> had (I do not know if that is the case, as I do not live in Apple\n>> ecosystem), it may give us a reason to special case the trailing\n>> double-dots, for example.\n> \n> Its not an Apple thing. I am not even using macOS at the first place\n> when I tested this, I was on Ubuntu running on my Mac.\n> \n> Its a problem with Net::Domain. In systems without a domainname, and\n> without a period in the hostname, Net::Domain will always output\n> \"hostname..\". You probably should check your machine with smtp-debug?\n> Btw, the output of `hostname -f` on these machines will be \"hostname\".\n> \n> Now gmail does not reject this, probably the reason it is unnoticed?\n> Since Outlook support is new, such problems are being observed.\n> \n> \n>> \n>> I personally feel that \"run of at most 63 alnum or dash separated by\n>> a single dot in between\" is easy enough to explain, so if I were\n>> doing this change, I would just use the regexp used in posted patch\n>> [*] and if nobody complains, stop right there.  If we get any\n>> complaint, then I'd detect and reject the case where the string ends\n>> with double-dots.\n> \n> The regexp used in the original patch covers the double dots case as well.\n> Its basically following the RFC guidelines, which a sensible SMTP server\n> should follow, and so must a user.\n> \n>> \n>> [Footnote]\n>> \n>> * ... but I don't know if your use of negative lookaround\n>>   assersions is correct.  Shouldn't the \"a label cannot begin or\n>>   end with dash\" be applied not just to the first label but\n>>   consistently to all of the dot-separated labels?\n> \n> I think you are talking about this case:\n> \n> someone.-example.com\n> \n> No, its not valid.a\n\nAlthough my regex is considering it as valid, which I can fix, but I'd rather wait\nfor us to come to a conclusion on how we are fixing this in the first place."},{"id":"517395","messageId":"xmqq4ixxh03n.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597E09838320FF9F403D255B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-06T21:59:24Z","receivedAt":"2025-05-06T21:59:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> As far as the script is concerned,\n>\n> - The script currently checks the presence of a period in the fqdn.\n\nI suspect that this is overly strict in a strictly local settings.\n\n> - At the same time, the script does NOT check whether the fqdn\n> starts or ends with a period.\n\nAs a DNS domainname, starting with is problematic, but ending with a\nperiod (e.g., \"example.com.\") should be OK, as long as the last\nlabel is truly a top-level domain name.  I however think \n\n> - Also, it does NOT check if 2 periods are together or not.\n\nThat does sound problematic.\n\n> a fqdn without a dot at all gets accepted by my Outlook server, ...\n> ... afterall no FQDN would have these things.\n\nTrue; we need to be careful here, though---after all the world is\nnot necessarily RFC 5321 compliant, as your Outlook server shows, if\naccepts a name without any dot and is not a top-level domain.\n\nSo I think \"one or more <upto 63 octet run of alnum or hyphen that\ndoes not begin or end with hyphen>, separated by a single dot in\nbetween each\" (which is probably what you wanted to say in your\nregexp, even though it wasn't clear to me if you restricted the\nsecond and subsequent labels like you did the first one correctly)\nwould be a reasonable check to have.\n\n"},{"id":"517396","messageId":"xmqqzffpfl57.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB959731081532150F5FE54875B889A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v3 1/3] send-mail: improve checks for valid_fqdn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-06T22:07:48Z","receivedAt":"2025-05-06T22:07:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n>>  * ... but I don't know if your use of negative lookaround\n>>    assersions is correct.  Shouldn't the \"a label cannot begin or\n>>    end with dash\" be applied not just to the first label but\n>>    consistently to all of the dot-separated labels?\n>\n> I think you are talking about this case:\n>\n> someone.-example.com\n>\n> No, its not valid.a\n\nI was not talking about any \"case\"; I was talking more about your\nregexp to catch invalid addresses.  From RFC 5321,\n\n    helo       = \"HELO\" SP Domain CRLF\n    Domain     = sub-domain *(\".\" sub-domain)\n    sub-domain = Let-dig [Ldh-str]\n    Let-dig    = ALPHA / DIGIT\n    Ldh-str    = *( ALPHA / DIGIT / \"-\" ) Let-dig\n\nso the syntax for first \"sub-domain\" applies equally to the other\n\"sub-domain\".  If \"-example\" cannot be the third-level subdomain,\nthen it equally cannot be the second-level, either, but IIRC, the\npatch had regexp that treated the first level differently from the\nrest.\n\n"},{"id":"517480","messageId":"PN3PR01MB9597208F139D23AF3436B16AB888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v4 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-07T12:33:04Z","receivedAt":"2025-05-07T12:37:23Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nP.S. I have used `git-credential-outlook` linked in the second and third\npatch for this email!\n\nv2: - Improve grammar and add missing \"\" in second patch.\n    - Separate footnotes and the trailer block with a blank line in the first\n      patch.\n\nv3: - Change link for email helpers since old one was too long.\n\nv4: - Improve log message of first and second patch.\n    - Update valid_fqdn check in first patch to allow one or more <upto 63\n      octet run of alnum or hyphen that does not begin or end with hyphen>,\n      separated by a single dot in between each.\n    - Revert the documentation regarding sending patches to a mailing list\n      in the second patch.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 61 +++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |  4 ++\n git-send-email.perl               |  3 +-\n 3 files changed, 59 insertions(+), 9 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517481","messageId":"PN3PR01MB95970B9EA9BCAFA8A4140F70B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597208F139D23AF3436B16AB888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v4 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-07T12:33:05Z","receivedAt":"2025-05-07T12:37:26Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain being passed\nto Outlook's servers was not valid.\n\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\n\nNotice that an invalid domain name \"MacBook..\" is sent by git-send-email.\nWe have a fallback code that checks output from Net::Domain::domainname()\nor asking domain method of an Net::SMTP instance to detect a misconfigured\nhostname and replace it with fallback \"localhost.localdomain\", but the\nvalid_fqdn apparently is failing to say \"MacBook..\" is not a valid fqdn.\n\nWith this patch, the rule used in valid_fqdn is tightened, the beginning\npart of the SMTP exchange looked like this:\n\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..17d26dffde 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,8 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517482","messageId":"PN3PR01MB959781C8A5B990B2CCB68836B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597208F139D23AF3436B16AB888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-07T12:33:06Z","receivedAt":"2025-05-07T12:37:28Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"OAuth2.0 is a new authentication method that is being used by many email\nproviders, including Outlook and Gmail. Recently, the Authen::SASL perl\nmodule has been updated to support OAuth2.0 authentication, thus making\nthe git-send-email script be able to use this authentication method as\nwell. So lets improve the documentation to reflect this change.\n\nI also had a hard time finding a reliable OAuth2.0 access token\ngenerator for Outlook and Gmail. So I added a link to the such\ngenerators which I developed myself after seaching through lots of code\nand API documentation to make things easier for others.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 61 +++++++++++++++++++++++++++----\n 1 file changed, 53 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..26df6514c1 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP Server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use 'git send-email' to send your patches through the Gmail SMTP server,\n+edit '~/.gitconfig' to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,6 +528,37 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n+You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n+`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP Server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, OAuth2.0 authentication must be used for Outlook.\n+\n+Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n+SMTP server with 'git send-email':\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n Once your commits are ready to be sent to the mailing list, run the\n following commands:\n \n@@ -536,9 +567,23 @@ following commands:\n \t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have a credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers for Gmail and Outlook\n+are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517483","messageId":"PN3PR01MB95975EE4AA37873235165E66B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597208F139D23AF3436B16AB888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v4 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-07T12:33:07Z","receivedAt":"2025-05-07T12:37:30Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..b49923db02 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517485","messageId":"PN3PR01MB9597715ABF9B773D4E5BE649B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB95970B9EA9BCAFA8A4140F70B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-07T12:48:03Z","receivedAt":"2025-05-07T12:48:11Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"> ---\n>  git-send-email.perl | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 4215f8f7e9..17d26dffde 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1359,7 +1359,8 @@ sub process_address_list {\n>  \n>  sub valid_fqdn {\n>  \tmy $domain = shift;\n> -\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n> +\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n> +\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/;\n>  }\n>  \n>  sub maildomain_net {\n\nFWIW, if you wanna test this regexp, this simple perl script could help:\n\n---->8----\n#!/usr/bin/perl\n\nmy @domains = (\"macbook\",\n               \"example.com\",\n               \"-bad.com\",\n               \"too..many.dots\",\n               \"good-domain.org\",\n               \"someone.-example.com\",\n               \"some.hdhd-.com\");\n\nforeach my $d (@domains) {\n    if ($d =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/) {\n        print \"$d => Valid\\n\";\n    } else {\n        print \"$d => Invalid\\n\";\n    }\n}\n----------\n\nAlso I am thinking of using `hostname -f` as a method to be used on Linux and macOS before\nusing the Net::Domain library.\n\n"},{"id":"517523","messageId":"xmqq5xicawp4.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB959781C8A5B990B2CCB68836B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T22:21:43Z","receivedAt":"2025-05-07T22:21:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> -EXAMPLES\n> ---------\n> -Use gmail as the smtp server\n> +EXAMPLES OF SMTP SERVERS\n> +------------------------\n> +Use Gmail as the SMTP Server\n\nNice to see that you got the capitalization got right while at it.\n\n>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n> -To use 'git send-email' to send your patches through the GMail SMTP server,\n> -edit ~/.gitconfig to specify your account settings:\n> +To use 'git send-email' to send your patches through the Gmail SMTP server,\n> +edit '~/.gitconfig' to specify your account settings:\n\nThe four single quotes above should probably be changed to back\nquotes, to match the \"You can also use OAuth2.0...\" below.\n\n> @@ -528,6 +528,37 @@ If you have multi-factor authentication set up on your Gmail account, you can\n>  generate an app-specific password for use with 'git send-email'. Visit\n>  https://security.google.com/settings/security/apppasswords to create it.\n>  \n> +You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n> +`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n> +\n> +----\n> +[sendemail]\n> +\tsmtpEncryption = tls\n> +\tsmtpServer = smtp.gmail.com\n> +\tsmtpUser = yourname@gmail.com\n> +\tsmtpServerPort = 587\n> +\tsmtpAuth = OAUTHBEARER\n> +----\n> +\n> +Use Microsoft Outlook as the SMTP Server\n> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n> +Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n> +Therefore, OAuth2.0 authentication must be used for Outlook.\n> +\n> +Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n> +SMTP server with 'git send-email':\n> +\n> +----\n> +[sendemail]\n> +\tsmtpEncryption = tls\n> +\tsmtpServer = smtp.office365.com\n> +\tsmtpUser = yourname@outlook.com\n> +\tsmtpServerPort = 587\n> +\tsmtpAuth = XOAUTH2\n> +----\n\nJust for my education, the above description does say why Outlook\nneeds to use OAuth2.0, but does not hint the reason for the\ndifference between the two example, OAUTHBEARER vs XOAUTH2.  Do\nthese two services support both, or does Gmail support only\nOAUTHBEARER while Outlook supports only XOAUTH2?  \n\nGiven that the former is described in RFC and the latter sometimes\ndescribed as \"Proprietary Google extension, not a standard\", it is\nsomewhat funny to see that Gmail example uses OAUTHBEARER while\nOutlook example uses XOAUTH2.\n\n> +SENDING PATCHES\n> +---------------\n>  Once your commits are ready to be sent to the mailing list, run the\n>  following commands:\n>  \n> @@ -536,9 +567,23 @@ following commands:\n>  \t$ git send-email outgoing/*\n>  \n>  The first time you run it, you will be prompted for your credentials.  Enter the\n> -app-specific or your regular password as appropriate.  If you have credential\n> -helper configured (see linkgit:git-credential[1]), the password will be saved in\n> -the credential store so you won't have to type it the next time.\n> +app-specific or your regular password as appropriate.\n> +\n> +If you have a credential helper configured (see linkgit:git-credential[1]), the\n> +password will be saved in the credential store so you won't have to type it the\n> +next time.\n> +\n> +If you are using OAuth2.0 authentication, you need to use an access token in\n> +place of a password when prompted. Various OAuth2.0 token generators are\n> +available online. Community maintained credential helpers for Gmail and Outlook\n> +are also available:\n> +\n> +\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n> +\n> +\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n\nGiven that this will be formatted via AsciiDoc (or asciidoctor),\nwould it make sense to make it easier for readers of the source\ndocument by folding lines, like:\n\n\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail]\n\t  (cross platform, dedicated helper for authenticating Gmail accounts)\n\n\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook]\n\t  (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n\nor something?\n\nOther than that, very nicely done.  Thanks.\n"},{"id":"517524","messageId":"xmqqzffo9h6v.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB95970B9EA9BCAFA8A4140F70B888A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 1/3] send-mail: improve checks for valid_fqdn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-07T22:42:00Z","receivedAt":"2025-05-07T22:42:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n>  sub valid_fqdn {\n>  \tmy $domain = shift;\n> -\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n> +\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n> +\t\t&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/;\n\nYuck, can we do something about this overly long mess?  \n\nIf use a temporary $subdomain = '(?!-)[A-Za-z0-9-]{1,63}(?<!-)',\nwould it make it easier to spot the repetition in the structure,\ni.e. /^$subdomain(?:\\.$subdomain)*$/ and make it less error prone\nwhen somebody has to touch lines around here, or something?\n\nBut other than that, looking good.\n\nEven though this allows \"foo.local\", on \"darwin\" it is still not\nallowed, which sounds like a regression-free change.\n\nThanks.\n"},{"id":"517530","messageId":"PN3PR01MB9597C4313236E59ABEF0B732B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqq5xicawp4.fsf@gitster.g","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T03:29:58Z","receivedAt":"2025-05-08T03:30:04Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 8 May 2025, at 3:51 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿\n>> \n>> -EXAMPLES\n>> ---------\n>> -Use gmail as the smtp server\n>> +EXAMPLES OF SMTP SERVERS\n>> +------------------------\n>> +Use Gmail as the SMTP Server\n> \n> Nice to see that you got the capitalization got right while at it.\n> \n>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>> -To use 'git send-email' to send your patches through the GMail SMTP server,\n>> -edit ~/.gitconfig to specify your account settings:\n>> +To use 'git send-email' to send your patches through the Gmail SMTP server,\n>> +edit '~/.gitconfig' to specify your account settings:\n> \n> The four single quotes above should probably be changed to back\n> quotes, to match the \"You can also use OAuth2.0...\" below.\n\nI think ~/.gitconfig should be in single quotes, its not a command.\n\n> \n>> @@ -528,6 +528,37 @@ If you have multi-factor authentication set up on your Gmail account, you can\n>> generate an app-specific password for use with 'git send-email'. Visit\n>> https://security.google.com/settings/security/apppasswords to create it.\n>> \n>> +You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n>> +`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n>> +\n>> +----\n>> +[sendemail]\n>> +    smtpEncryption = tls\n>> +    smtpServer = smtp.gmail.com\n>> +    smtpUser = yourname@gmail.com\n>> +    smtpServerPort = 587\n>> +    smtpAuth = OAUTHBEARER\n>> +----\n>> +\n>> +Use Microsoft Outlook as the SMTP Server\n>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n>> +Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n>> +Therefore, OAuth2.0 authentication must be used for Outlook.\n>> +\n>> +Edit '~/.gitconfig' to specify your account settings for Outlook and use its\n>> +SMTP server with 'git send-email':\n>> +\n>> +----\n>> +[sendemail]\n>> +    smtpEncryption = tls\n>> +    smtpServer = smtp.office365.com\n>> +    smtpUser = yourname@outlook.com\n>> +    smtpServerPort = 587\n>> +    smtpAuth = XOAUTH2\n>> +----\n> \n> Just for my education, the above description does say why Outlook\n> needs to use OAuth2.0, but does not hint the reason for the\n> difference between the two example, OAUTHBEARER vs XOAUTH2.  Do\n> these two services support both, or does Gmail support only\n> OAUTHBEARER while Outlook supports only XOAUTH2?  \n\nGmail supports for OAUTHBEARER and XOAUTH2. I added OAUTHBEARER\njust for the sake of a different example. I think addding a choice between two\nwill just cause confusion among people.\n\nOutlook supports only XOAUTH2 (which is surprising since OAUTHBEARER\nis described in RFC, and XOAUTH2 is Google's).\n> \n> Given that the former is described in RFC and the latter sometimes\n> described as \"Proprietary Google extension, not a standard\", it is\n> somewhat funny to see that Gmail example uses OAUTHBEARER while\n> Outlook example uses XOAUTH2.\n> \n>> +SENDING PATCHES\n>> +---------------\n>> Once your commits are ready to be sent to the mailing list, run the\n>> following commands:\n>> \n>> @@ -536,9 +567,23 @@ following commands:\n>>    $ git send-email outgoing/*\n>> \n>> The first time you run it, you will be prompted for your credentials.  Enter the\n>> -app-specific or your regular password as appropriate.  If you have credential\n>> -helper configured (see linkgit:git-credential[1]), the password will be saved in\n>> -the credential store so you won't have to type it the next time.\n>> +app-specific or your regular password as appropriate.\n>> +\n>> +If you have a credential helper configured (see linkgit:git-credential[1]), the\n>> +password will be saved in the credential store so you won't have to type it the\n>> +next time.\n>> +\n>> +If you are using OAuth2.0 authentication, you need to use an access token in\n>> +place of a password when prompted. Various OAuth2.0 token generators are\n>> +available online. Community maintained credential helpers for Gmail and Outlook\n>> +are also available:\n>> +\n>> +    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper for authenticating Gmail accounts)\n>> +\n>> +    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n> \n> Given that this will be formatted via AsciiDoc (or asciidoctor),\n> would it make sense to make it easier for readers of the source\n> document by folding lines, like:\n> \n>    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail]\n>      (cross platform, dedicated helper for authenticating Gmail accounts)\n> \n>    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook]\n>      (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n> \n> or something?\n> \n> Other than that, very nicely done.  Thanks.\n"},{"id":"517542","messageId":"PN3PR01MB9597B28DEE072C9D452EDB68B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqzffo9h6v.fsf@gitster.g","subject":"Re: [PATCH v4 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T10:38:06Z","receivedAt":"2025-05-08T10:38:13Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"> Yuck, can we do something about this overly long mess?  \n> \n> If use a temporary $subdomain = '(?!-)[A-Za-z0-9-]{1,63}(?<!-)',\n> would it make it easier to spot the repetition in the structure,\n> i.e. /^$subdomain(?:\\.$subdomain)*$/ and make it less error prone\n> when somebody has to touch lines around here, or something?\n> \n> But other than that, looking good.\n> \n> Even though this allows \"foo.local\", on \"darwin\" it is still not\n> allowed, which sounds like a regression-free change\n\nSent a version 5 here: https://lore.kernel.org/git/PN3PR01MB95974932FF37D9F24A7633C6B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM/T/#t\n\nI forgot to add --in-reply-to while using git send-email to send v5, so it got sent\nas a separate thread by mistake.\n"},{"id":"517549","messageId":"xmqqwmar8bw9.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597C4313236E59ABEF0B732B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-08T13:33:58Z","receivedAt":"2025-05-08T13:34:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n>>> -To use 'git send-email' to send your patches through the GMail SMTP server,\n>>> -edit ~/.gitconfig to specify your account settings:\n>>> +To use 'git send-email' to send your patches through the Gmail SMTP server,\n>>> +edit '~/.gitconfig' to specify your account settings:\n>> \n>> The four single quotes above should probably be changed to back\n>> quotes, to match the \"You can also use OAuth2.0...\" below.\n>\n> I think ~/.gitconfig should be in single quotes, its not a command.\n\n\"Is this something the end-user would type verbatim?\" is the criteria,\nnot \"Is this a command name?\".\n\n> Gmail supports for OAUTHBEARER and XOAUTH2. I added OAUTHBEARER\n> just for the sake of a different example. I think adding a choice\n> between two will just cause confusion among people.\n>\n> Outlook supports only XOAUTH2 (which is surprising since OAUTHBEARER\n> is described in RFC, and XOAUTH2 is Google's).\n\nYour examples that show that smtpAuth can take these different\nvalues are certainly good.  As we know what these two services\nsupport, it is worth saying, no?  Unless it is like Gmail supports\nboth but git-send-email for whatever reason can use only one of them\nto talk to Gmail, that is.\n\nThanks.\n"},{"id":"517553","messageId":"PN3PR01MB95972BB022C2297D3E52DE78B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqwmar8bw9.fsf@gitster.g","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T13:52:26Z","receivedAt":"2025-05-08T13:52:31Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 8 May 2025, at 7:04 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>>>> -To use 'git send-email' to send your patches through the GMail SMTP server,\n>>>> -edit ~/.gitconfig to specify your account settings:\n>>>> +To use 'git send-email' to send your patches through the Gmail SMTP server,\n>>>> +edit '~/.gitconfig' to specify your account settings:\n>>> \n>>> The four single quotes above should probably be changed to back\n>>> quotes, to match the \"You can also use OAuth2.0...\" below.\n>> \n>> I think ~/.gitconfig should be in single quotes, its not a command.\n> \n> \"Is this something the end-user would type verbatim?\" is the criteria,\n\nSo the end user won't type it. It's just a path of a file to be edited.\nIf you still want to change it to backticks, I'll change it. Do confirm the same btw.\n\n> not \"Is this a command name?\".\n> \n>> Gmail supports for OAUTHBEARER and XOAUTH2. I added OAUTHBEARER\n>> just for the sake of a different example. I think adding a choice\n>> between two will just cause confusion among people.\n>> \n>> Outlook supports only XOAUTH2 (which is surprising since OAUTHBEARER\n>> is described in RFC, and XOAUTH2 is Google's).\n> \n> Your examples that show that smtpAuth can take these different\n> values are certainly good.  As we know what these two services\n> support, it is worth saying, no?  Unless it is like Gmail supports\n> both but git-send-email for whatever reason can use only one of them\n> to talk to Gmail, that is.\n\ngit send email can use any smtpAuth method that is supported by Authen::SASL\nand the server. So using XOAUTH2 with gmail will also work just fine.\n\nAs far as giving information about supported authentication methods is concerned,\nwe are writing an example, not giving a detailed guide with the providers docs.\nAlso, by this logic, Gmail also supports smtpAuth=LOGIN with app passwords.\nPlus, anyone reading this guide would most likely be a newbie, who will be more\ninterested in \"how to get this thing working\" than knowing \"oh, I can use XOAUTH2\nas well in gmail\". Infact mentioning both options will just make him wonder on\nwhat option is better, XOAUTH2 or OAUTHBEARER, which practically are the same\nin terms of access tokens and other stuff. The only difference is \"how is the access\ntoken formatted and sent to the server\", which is done at a lower level by\nAuthen::SASL, and isn't really a concern for users. In short, the same access token\nworks for both XOAUTH2 and OAUTHBEARER. As far as \"what actually is supported\nby my email provider\", is concerned, just consult their docs. That's what a curious\nadvanced user would want to know and I belive he is very capable to figure that\nout."},{"id":"517557","messageId":"xmqqcycj888l.fsf@gitster.g","threadId":"63393","inReplyTo":"xmqqwmar8bw9.fsf@gitster.g","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-08T14:52:58Z","receivedAt":"2025-05-08T14:53:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> I think ~/.gitconfig should be in single quotes, its not a command.\n>\n> \"Is this something the end-user would type verbatim?\" is the criteria,\n> not \"Is this a command name?\".\n\nLooking for \"^Markup:\" in Documentation/CodingGuidelines, we find a\nbetter description.\n\n Literal parts (e.g. use of command-line options, command names,\n branch names, URLs, pathnames (files and directories), configuration and\n environment variables) must be typeset as verbatim (i.e. wrapped with\n backticks):\n   `--pretty=oneline`\n   `git rev-list`\n   `remote.pushDefault`\n   `http://git.example.com`\n   `.git/config`\n   `GIT_DIR`\n   `HEAD`\n   `umask`(2)\n\n"},{"id":"517559","messageId":"PN3PR01MB959761BC7EF27EE2CFB1134BB88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqcycj888l.fsf@gitster.g","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:05:11Z","receivedAt":"2025-05-08T15:05:18Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 8 May 2025, at 8:23 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Junio C Hamano <gitster@pobox.com> writes:\n> \n>>> I think ~/.gitconfig should be in single quotes, its not a command.\n>> \n>> \"Is this something the end-user would type verbatim?\" is the criteria,\n>> not \"Is this a command name?\".\n> \n> Looking for \"^Markup:\" in Documentation/CodingGuidelines, we find a\n> better description.\n> \n> Literal parts (e.g. use of command-line options, command names,\n> branch names, URLs, pathnames (files and directories), configuration and\n> environment variables) must be typeset as verbatim (i.e. wrapped with\n> backticks):\n>   `--pretty=oneline`\n>   `git rev-list`\n>   `remote.pushDefault`\n>   `http://git.example.com`\n>   `.git/config`\n>   `GIT_DIR`\n>   `HEAD`\n>   `umask`(2)\n> \n\nI see. Since you have already queued the v5, can you do this change on your end,\nor should I send a v6?\n\nAlso, if this is true, the docs need a review since I've found inconsistency across\nmany places."},{"id":"517560","messageId":"PN3PR01MB9597E7D76464369382B38B53B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB959761BC7EF27EE2CFB1134BB88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:08:00Z","receivedAt":"2025-05-08T15:08:06Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 8 May 2025, at 8:35 PM, Aditya Garg <gargaditya08@live.com> wrote:\n> \n> ﻿\n> \n>> On 8 May 2025, at 8:23 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> \n>> ﻿Junio C Hamano <gitster@pobox.com> writes:\n>> \n>>>> I think ~/.gitconfig should be in single quotes, its not a command.\n>>> \n>>> \"Is this something the end-user would type verbatim?\" is the criteria,\n>>> not \"Is this a command name?\".\n>> \n>> Looking for \"^Markup:\" in Documentation/CodingGuidelines, we find a\n>> better description.\n>> \n>> Literal parts (e.g. use of command-line options, command names,\n>> branch names, URLs, pathnames (files and directories), configuration and\n>> environment variables) must be typeset as verbatim (i.e. wrapped with\n>> backticks):\n>>  `--pretty=oneline`\n>>  `git rev-list`\n>>  `remote.pushDefault`\n>>  `http://git.example.com`\n>>  `.git/config`\n>>  `GIT_DIR`\n>>  `HEAD`\n>>  `umask`(2)\n>> \n> \n> I see. Since you have already queued the v5, can you do this change on your end,\n> or should I send a v6?\n\nGuess what, I'll just send a version 6. Its not a big change.\n"},{"id":"517563","messageId":"PN0PR01MB9588B04D666EBB98AE6EA378B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v6 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:18:40Z","receivedAt":"2025-05-08T15:22:22Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nP.S. I have used `git-credential-outlook` linked in the second and third\npatch for this email!\n\nv2: - Improve grammar and add missing \"\" in second patch.\n    - Separate footnotes and the trailer block with a blank line in the first\n      patch.\n\nv3: - Change link for email helpers since old one was too long.\n\nv4: - Improve log message of first and second patch.\n    - Update valid_fqdn check in first patch to allow one or more <upto 63\n      octet run of alnum or hyphen that does not begin or end with hyphen>,\n      separated by a single dot in between each.\n    - Revert the documentation regarding sending patches to a mailing list\n      in the second patch.\n\nv5: - Simplify the regex in the first patch to check for valid FQDN.\n    - Fix formatting in the second patch to make it more readable.\n\nv6: - Use backticks for ~/.gitconfig in the second patch.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 63 +++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |  4 ++\n git-send-email.perl               |  4 +-\n 3 files changed, 62 insertions(+), 9 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517564","messageId":"PN0PR01MB958852DAEEB74C087D43FFECB88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB9588B04D666EBB98AE6EA378B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v6 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:18:41Z","receivedAt":"2025-05-08T15:22:24Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain being passed\nto Outlook's servers was not valid.\n\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\n\nNotice that an invalid domain name \"MacBook..\" is sent by git-send-email.\nWe have a fallback code that checks output from Net::Domain::domainname()\nor asking domain method of an Net::SMTP instance to detect a misconfigured\nhostname and replace it with fallback \"localhost.localdomain\", but the\nvalid_fqdn apparently is failing to say \"MacBook..\" is not a valid fqdn.\n\nWith this patch, the rule used in valid_fqdn is tightened, the beginning\npart of the SMTP exchange looked like this:\n\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..55b7e00d29 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,9 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\tmy $subdomain = '(?!-)[A-Za-z0-9-]{1,63}(?<!-)';\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^$subdomain(?:\\.$subdomain)*$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517565","messageId":"PN0PR01MB9588D67C07DF041A8CB5FF12B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB9588B04D666EBB98AE6EA378B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v6 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:18:42Z","receivedAt":"2025-05-08T15:22:27Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"OAuth2.0 is a new authentication method that is being used by many email\nproviders, including Outlook and Gmail. Recently, the Authen::SASL perl\nmodule has been updated to support OAuth2.0 authentication, thus making\nthe git-send-email script be able to use this authentication method as\nwell. So lets improve the documentation to reflect this change.\n\nI also had a hard time finding a reliable OAuth2.0 access token\ngenerator for Outlook and Gmail. So I added a link to the such\ngenerators which I developed myself after seaching through lots of code\nand API documentation to make things easier for others.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 63 +++++++++++++++++++++++++++----\n 1 file changed, 55 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..f4503a776d 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP Server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use `git send-email` to send your patches through the Gmail SMTP server,\n+edit `~/.gitconfig` to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,6 +528,37 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n+You can also use OAuth2.0 authentication with Gmail. To do this, edit your\n+`~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP Server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, OAuth2.0 authentication must be used for Outlook.\n+\n+Edit `~/.gitconfig` to specify your account settings for Outlook and use its\n+SMTP server with `git send-email`:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n Once your commits are ready to be sent to the mailing list, run the\n following commands:\n \n@@ -536,9 +567,25 @@ following commands:\n \t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have a credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers for Gmail and Outlook\n+are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail]\n+\t  (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook]\n+\t  (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517566","messageId":"PN0PR01MB95888E9CFF5D07D26D4A4DB4B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB9588B04D666EBB98AE6EA378B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v6 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T15:18:43Z","receivedAt":"2025-05-08T15:22:29Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..b49923db02 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517571","messageId":"xmqq7c2r6phg.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB95972BB022C2297D3E52DE78B88BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-08T16:23:23Z","receivedAt":"2025-05-08T16:23:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n>> \"Is this something the end-user would type verbatim?\" is the criteria,\n>\n> So the end user won't type it. It's just a path of a file to be edited.\n> If you still want to change it to backticks, I'll change it. Do confirm the same btw.\n>\n>> not \"Is this a command name?\".\n\nThen perhaps 'type' -> 'use'; the idea is the same.  Are we showing\nthe exact concrete thing (e.g. \"file at this path, which you would\nspell `like so`\") or a concept (e.g. \"per-user configuration file\")?\nThe `literal` mark-up is for the former.\n\n> git send email can use any smtpAuth method that is supported by Authen::SASL\n> and the server. So using XOAUTH2 with gmail will also work just fine.\n\nOK.\n\n> As far as giving information about supported authentication methods is concerned,\n> we are writing an example, not giving a detailed guide with the providers docs.\n\nYes, but giving a passing mention, like\n\n\tYou can also use OAuth2.0 authentication with Gmail.  Edit\n\t`~/.gitconfig` and set `sendemail.smtpAuth = OAUTHBEARER`\n\tthere (they support both XOAUTH2 and OAUTHBEARER, but the\n\tlatter is more recent and in the standard):\n\n\t---\n\t... example here ...\n\t---\t\n\nwould make it easier to see to those who learn from elsewhere that\nthey can use their e-mail client (not `git send-email`) with Gmail\nwith OAuth, come here because they want to use the same account with\n`git send-email` too.  If that 'elsewhere' only mentioned XOAUTH2,\nwriting something like the above would be more helpful than using\nOAUTHBEARER without mentioning XOAUTH2 at all, no?\n\n> Also, by this logic, Gmail also supports smtpAuth=LOGIN with app passwords.\n\nBut the question we need to answer is: does talking about it help\nwhen people want to learn how to use OAuth2.0 instead of plain\nvanilla password login?  I think talking about smtpAuth=OAUTHBEARER\nand smtpAuth=XOAUTH2 does help; does talking about smtpAuth=LOGIN\nhelp?\n\nSo, no, LOGIN is irrelevant, and I do not quite see the above as\nmaking a meaningful analogy \"by this logic\".\n\n> Plus, anyone reading this guide would most likely be a newbie, who will be more\n> interested in \"how to get this thing working\" than knowing \"oh, I can use XOAUTH2\n> as well in gmail\".\n\nI am suggeting that you can cater to both of them with minimum\neffort.  A newbie can fall into the latter class; those who used\nXOAUTH2 when setting up other software (hence they know XOAUTH2\nworks with Gmail) but did not know that OAUTHBEARER also worked as\nwell.\n\nThanks.\n"},{"id":"517573","messageId":"PN0PR01MB9588D6EE5C0719810B836463B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqq7c2r6phg.fsf@gitster.g","subject":"Re: [PATCH v4 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T16:38:55Z","receivedAt":"2025-05-08T16:39:00Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 8 May 2025, at 9:53 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>>> \"Is this something the end-user would type verbatim?\" is the criteria,\n>> \n>> So the end user won't type it. It's just a path of a file to be edited.\n>> If you still want to change it to backticks, I'll change it. Do confirm the same btw.\n>> \n>>> not \"Is this a command name?\".\n> \n> Then perhaps 'type' -> 'use'; the idea is the same.  Are we showing\n> the exact concrete thing (e.g. \"file at this path, which you would\n> spell `like so`\") or a concept (e.g. \"per-user configuration file\")?\n> The `literal` mark-up is for the former.\n> \n>> git send email can use any smtpAuth method that is supported by Authen::SASL\n>> and the server. So using XOAUTH2 with gmail will also work just fine.\n> \n> OK.\n> \n>> As far as giving information about supported authentication methods is concerned,\n>> we are writing an example, not giving a detailed guide with the providers docs.\n> \n> Yes, but giving a passing mention, like\n> \n>    You can also use OAuth2.0 authentication with Gmail.  Edit\n>    `~/.gitconfig` and set `sendemail.smtpAuth = OAUTHBEARER`\n>    there (they support both XOAUTH2 and OAUTHBEARER, but the\n>    latter is more recent and in the standard):\n> \n>    ---\n>    ... example here ...\n>    ---    \n> \n> would make it easier to see to those who learn from elsewhere that\n> they can use their e-mail client (not `git send-email`) with Gmail\n> with OAuth, come here because they want to use the same account with\n> `git send-email` too.  If that 'elsewhere' only mentioned XOAUTH2,\n> writing something like the above would be more helpful than using\n> OAUTHBEARER without mentioning XOAUTH2 at all, no?\n> \n>> Also, by this logic, Gmail also supports smtpAuth=LOGIN with app passwords.\n> \n> But the question we need to answer is: does talking about it help\n> when people want to learn how to use OAuth2.0 instead of plain\n> vanilla password login?  I think talking about smtpAuth=OAUTHBEARER\n> and smtpAuth=XOAUTH2 does help; does talking about smtpAuth=LOGIN\n> help?\n> \n> So, no, LOGIN is irrelevant, and I do not quite see the above as\n> making a meaningful analogy \"by this logic\".\n> \n>> Plus, anyone reading this guide would most likely be a newbie, who will be more\n>> interested in \"how to get this thing working\" than knowing \"oh, I can use XOAUTH2\n>> as well in gmail\".\n> \n> I am suggeting that you can cater to both of them with minimum\n> effort.  A newbie can fall into the latter class; those who used\n> XOAUTH2 when setting up other software (hence they know XOAUTH2\n> works with Gmail) but did not know that OAUTHBEARER also worked as\n> well.\n> \n> Thanks.\n\n\nAlright. I'll just add some docs regarding this then"},{"id":"517580","messageId":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597FADD19D6BBCE3FCD4FBCB88F2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v7 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T17:14:26Z","receivedAt":"2025-05-08T17:18:14Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"Hi all\n\nThis series of patches mainly has two changes:\n\n1. Improve the checks for valid_fqdn in send-email to be more strict and\n   compliant with RFC1035.\n2. Update the documentation for send-email to include examples of using\n   OAuth2.0 with Gmail and Outlook, as well as links to the credential\n   helpers for these services.\n\nP.S. I have used `git-credential-outlook` linked in the second and third\npatch for this email!\n\nv2: - Improve grammar and add missing \"\" in second patch.\n    - Separate footnotes and the trailer block with a blank line in the first\n      patch.\n\nv3: - Change link for email helpers since old one was too long.\n\nv4: - Improve log message of first and second patch.\n    - Update valid_fqdn check in first patch to allow one or more <upto 63\n      octet run of alnum or hyphen that does not begin or end with hyphen>,\n      separated by a single dot in between each.\n    - Revert the documentation regarding sending patches to a mailing list\n      in the second patch.\n\nv5: - Simplify the regex in the first patch to check for valid FQDN.\n    - Fix formatting in the second patch to make it more readable.\n\nv6: - Use backticks for ~/.gitconfig in the second patch.\n\nv7: - Clarify the use of `OAUTHBEARER` and `XOAUTH2` in the second patch.\n\nAditya Garg (3):\n  send-mail: improve checks for valid_fqdn\n  docs: improve send-email documentation\n  docs: add credential helper for outlook and gmail in OAuth list of\n    helpers\n\n Documentation/git-send-email.adoc | 67 +++++++++++++++++++++++++++----\n Documentation/gitcredentials.adoc |  4 ++\n git-send-email.perl               |  4 +-\n 3 files changed, 66 insertions(+), 9 deletions(-)\n\n-- \n2.49.0\n\n"},{"id":"517581","messageId":"PN0PR01MB958809A9F52D140ABD917881B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v7 1/3] send-mail: improve checks for valid_fqdn","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T17:14:27Z","receivedAt":"2025-05-08T17:18:18Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"The current implementation of a valid Fully Qualified Domain Name\nis not that strict. It just checks whether it has a dot (.) and\nif using macOS, it should not end with .local. As per RFC1035[1],\nfrom what I understood, the following checks need to be done:\n\n- The domain must contain atleast one dot\n- Each label (separated by dots) must be 1-63 characters long\n- Labels must start and end with an alphanumeric character\n- Labels can contain alphanumeric characters and hyphens\n\nHere are some examples of valid and invalid labels:\n\n'example.com',          # Valid\n'sub.example.com',      # Valid\n'my-domain.org',        # Valid\n'localhost',            # Invalid (no dot)\n'MacBook..',            # Invalid (double dots)\n'-example.com',         # Invalid (starts with a hyphen)\n'example-.com',         # Invalid (ends with a hyphen)\n'example..com',         # Invalid (double dots)\n'example',              # Invalid (no TLD)\n'example.local',        # Invalid on macOS\n'valid-domain.co.uk',   # Valid\n'123.example.com',      # Valid\n'example.com.',         # Invalid (trailing dot)\n'toolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabeltoolonglabel.com', # Invalid (label > 63 chars)\n\nDue to current implementation, I was not able to send emails from\nUbuntu. Upon debugging, I found that the SMTP domain being passed\nto Outlook's servers was not valid.\n\nNet::SMTP=GLOB(0x5db4351225f8)>>> EHLO MacBook..\nNet::SMTP=GLOB(0x5db4351225f8)<<< 501 5.5.4 Invalid domain name\nNet::SMTP=GLOB(0x5db4351225f8)>>> HELO MacBook..\n\nNotice that an invalid domain name \"MacBook..\" is sent by git-send-email.\nWe have a fallback code that checks output from Net::Domain::domainname()\nor asking domain method of an Net::SMTP instance to detect a misconfigured\nhostname and replace it with fallback \"localhost.localdomain\", but the\nvalid_fqdn apparently is failing to say \"MacBook..\" is not a valid fqdn.\n\nWith this patch, the rule used in valid_fqdn is tightened, the beginning\npart of the SMTP exchange looked like this:\n\nNet::SMTP=GLOB(0x58c8af71e930)>>> EHLO localhost.localdomain\nNet::SMTP=GLOB(0x58c8af71e930)<<< 250-PN4P287CA0064.outlook.office365.com Hello\n\n[1]: https://datatracker.ietf.org/doc/html/rfc1035\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4215f8f7e9..55b7e00d29 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1359,7 +1359,9 @@ sub process_address_list {\n \n sub valid_fqdn {\n \tmy $domain = shift;\n-\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/) && $domain =~ /\\./;\n+\tmy $subdomain = '(?!-)[A-Za-z0-9-]{1,63}(?<!-)';\n+\treturn defined $domain && !($^O eq 'darwin' && $domain =~ /\\.local$/)\n+\t\t&& $domain  =~ /^$subdomain(?:\\.$subdomain)*$/;\n }\n \n sub maildomain_net {\n-- \n2.49.0\n\n"},{"id":"517582","messageId":"PN0PR01MB958890D936BE35C2D7AF1C85B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v7 2/3] docs: improve send-email documentation","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T17:14:28Z","receivedAt":"2025-05-08T17:18:20Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"OAuth2.0 is a new authentication method that is being used by many email\nproviders, including Outlook and Gmail. Recently, the Authen::SASL perl\nmodule has been updated to support OAuth2.0 authentication, thus making\nthe git-send-email script be able to use this authentication method as\nwell. So lets improve the documentation to reflect this change.\n\nI also had a hard time finding a reliable OAuth2.0 access token\ngenerator for Outlook and Gmail. So I added a link to the such\ngenerators which I developed myself after seaching through lots of code\nand API documentation to make things easier for others.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/git-send-email.adoc | 67 +++++++++++++++++++++++++++----\n 1 file changed, 59 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc\nindex 92389036fa..26fda63c2f 100644\n--- a/Documentation/git-send-email.adoc\n+++ b/Documentation/git-send-email.adoc\n@@ -509,12 +509,12 @@ include::includes/cmd-config-section-all.adoc[]\n \n include::config/sendemail.adoc[]\n \n-EXAMPLES\n---------\n-Use gmail as the smtp server\n+EXAMPLES OF SMTP SERVERS\n+------------------------\n+Use Gmail as the SMTP Server\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n-To use 'git send-email' to send your patches through the GMail SMTP server,\n-edit ~/.gitconfig to specify your account settings:\n+To use `git send-email` to send your patches through the Gmail SMTP server,\n+edit `~/.gitconfig` to specify your account settings:\n \n ----\n [sendemail]\n@@ -528,6 +528,41 @@ If you have multi-factor authentication set up on your Gmail account, you can\n generate an app-specific password for use with 'git send-email'. Visit\n https://security.google.com/settings/security/apppasswords to create it.\n \n+You can also use OAuth2.0 authentication with Gmail. `OAUTHBEARER` and\n+`XOAUTH2` are common methods used for this type of authentication. Gmail\n+supports both of them. As an example, if you want to use `OAUTHBEARER`, edit\n+your `~/.gitconfig` file and add `smtpAuth = OAUTHBEARER` to your account\n+settings:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.gmail.com\n+\tsmtpUser = yourname@gmail.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = OAUTHBEARER\n+----\n+\n+Use Microsoft Outlook as the SMTP Server\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+Unlike Gmail, Microsoft Outlook no longer supports app-specific passwords.\n+Therefore, OAuth2.0 authentication must be used for Outlook. Also, it only\n+supports `XOAUTH2` authentication method.\n+\n+Edit `~/.gitconfig` to specify your account settings for Outlook and use its\n+SMTP server with `git send-email`:\n+\n+----\n+[sendemail]\n+\tsmtpEncryption = tls\n+\tsmtpServer = smtp.office365.com\n+\tsmtpUser = yourname@outlook.com\n+\tsmtpServerPort = 587\n+\tsmtpAuth = XOAUTH2\n+----\n+\n+SENDING PATCHES\n+---------------\n Once your commits are ready to be sent to the mailing list, run the\n following commands:\n \n@@ -536,9 +571,25 @@ following commands:\n \t$ git send-email outgoing/*\n \n The first time you run it, you will be prompted for your credentials.  Enter the\n-app-specific or your regular password as appropriate.  If you have credential\n-helper configured (see linkgit:git-credential[1]), the password will be saved in\n-the credential store so you won't have to type it the next time.\n+app-specific or your regular password as appropriate.\n+\n+If you have a credential helper configured (see linkgit:git-credential[1]), the\n+password will be saved in the credential store so you won't have to type it the\n+next time.\n+\n+If you are using OAuth2.0 authentication, you need to use an access token in\n+place of a password when prompted. Various OAuth2.0 token generators are\n+available online. Community maintained credential helpers for Gmail and Outlook\n+are also available:\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail]\n+\t  (cross platform, dedicated helper for authenticating Gmail accounts)\n+\n+\t- https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook]\n+\t  (cross platform, dedicated helper for authenticating Microsoft Outlook accounts)\n+\n+You can also see linkgit:gitcredentials[7] for more OAuth based authentication\n+helpers.\n \n Note: the following core Perl modules that may be installed with your\n distribution of Perl are required:\n-- \n2.49.0\n\n"},{"id":"517583","messageId":"PN0PR01MB95884C84C8DCEF388CCFEEA1B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v7 3/3] docs: add credential helper for outlook and gmail in OAuth list of helpers","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-08T17:14:29Z","receivedAt":"2025-05-08T17:18:23Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"This commit adds the `git-credential-outlook` and `git-credential-gmail`\nhelpers to the list of OAuth helpers.\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n Documentation/gitcredentials.adoc | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..b49923db02 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -133,6 +133,10 @@ Popular helpers with OAuth support include:\n \n     - https://github.com/hickford/git-credential-oauth[git-credential-oauth] (cross platform, included in many Linux distributions)\n \n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-gmail] (cross platform, dedicated helper to authenticate Gmail accounts for linkgit:git-send-email[1])\n+\n+    - https://github.com/AdityaGarg8/git-credential-email[git-credential-outlook] (cross platform, dedicated helper to authenticate Microsoft Outlook accounts for linkgit:git-send-email[1])\n+\n CREDENTIAL CONTEXTS\n -------------------\n \n-- \n2.49.0\n\n"},{"id":"517585","messageId":"xmqqzffn561f.fsf@gitster.g","threadId":"63393","inReplyTo":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v7 0/3] Improve checks for valid_fqdn in send-email and update documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-08T18:08:44Z","receivedAt":"2025-05-08T18:08:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> Hi all\n>\n> This series of patches mainly has two changes:\n>\n> 1. Improve the checks for valid_fqdn in send-email to be more strict and\n>    compliant with RFC1035.\n> 2. Update the documentation for send-email to include examples of using\n>    OAuth2.0 with Gmail and Outlook, as well as links to the credential\n>    helpers for these services.\n>\n> P.S. I have used `git-credential-outlook` linked in the second and third\n> patch for this email!\n>\n> v2: - Improve grammar and add missing \"\" in second patch.\n>     - Separate footnotes and the trailer block with a blank line in the first\n>       patch.\n>\n> v3: - Change link for email helpers since old one was too long.\n>\n> v4: - Improve log message of first and second patch.\n>     - Update valid_fqdn check in first patch to allow one or more <upto 63\n>       octet run of alnum or hyphen that does not begin or end with hyphen>,\n>       separated by a single dot in between each.\n>     - Revert the documentation regarding sending patches to a mailing list\n>       in the second patch.\n>\n> v5: - Simplify the regex in the first patch to check for valid FQDN.\n>     - Fix formatting in the second patch to make it more readable.\n>\n> v6: - Use backticks for ~/.gitconfig in the second patch.\n>\n> v7: - Clarify the use of `OAUTHBEARER` and `XOAUTH2` in the second patch.\n\nMuch better than what I came up with ;-)  Nicely phrased.\n\nWill queue.  Unless there are issues pointed out by others in a few\ndays, let me mark the topic for 'next'.\n\nThanks.\n"},{"id":"517698","messageId":"PN3PR01MB9597C419019DC28E489D2AF9B88AA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN0PR01MB95882173451A6A7C28AD7BE7B88BA@PN0PR01MB9588.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-09T16:49:58Z","receivedAt":"2025-05-09T16:50:15Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"`hostname` is a popular command available on both Linux and macOS. As\nper the man-page[1], `hostname --fqdn` command returns the fully\nqualified domain name (FQDN) of the system. The current Net::Domain\nperl module being used in the script for the same has been quite\nunrealiable in many cases. Thankfully, we now have a better check for\nvalid_fqdn, which does reject the invalid FQDNs given by this module\nproperly, but at the same time, it will result in a fallback to\n'localhost.localdomain' being used. `hostname --fqdn` has been quite\nreliable (probably even more reliable than the Net::Domain module) and\nbefore falling back to 'localhost.localdomain', we should try to use it.\nInterestingly, the `hostname` command is actually used by perl modules\nlike Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets\ngive `hostname --fqdn` a chance as well!\n\n[1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\n git-send-email.perl | 14 +++++++++++++-\n 1 file changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 55b7e00d29..735d8abc12 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1393,8 +1393,20 @@ sub maildomain_mta {\n \treturn $maildomain;\n }\n \n+sub maildomain_hostname_command {\n+\tmy $maildomain;\n+\n+\tif ($^O eq 'linux' || $^O eq 'darwin') {\n+\t\tmy $domain = `(hostname --fqdn) 2>/dev/null`;\n+\t\tchomp($domain);\n+\t\t$maildomain = $domain if valid_fqdn($domain);\n+\t}\n+\treturn $maildomain;\n+}\n+\n sub maildomain {\n-\treturn maildomain_net() || maildomain_mta() || 'localhost.localdomain';\n+\treturn maildomain_net() || maildomain_mta() ||\n+\t\tmaildomain_hostname_command || 'localhost.localdomain';\n }\n \n sub smtp_host_string {\n-- \n2.49.0\n\n"},{"id":"517708","messageId":"xmqqseldzgoh.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597C419019DC28E489D2AF9B88AA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-09T20:13:02Z","receivedAt":"2025-05-09T20:13:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> `hostname` is a popular command available on both Linux and macOS. As\n> per the man-page[1], `hostname --fqdn` command returns the fully\n> qualified domain name (FQDN) of the system. The current Net::Domain\n> perl module being used in the script for the same has been quite\n> unrealiable in many cases. Thankfully, we now have a better check for\n> valid_fqdn, which does reject the invalid FQDNs given by this module\n> properly, but at the same time, it will result in a fallback to\n> 'localhost.localdomain' being used. `hostname --fqdn` has been quite\n> reliable (probably even more reliable than the Net::Domain module) and\n> before falling back to 'localhost.localdomain', we should try to use it.\n> Interestingly, the `hostname` command is actually used by perl modules\n> like Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets\n> give `hostname --fqdn` a chance as well!\n>\n> [1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n> [2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n> [3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n>\n> Signed-off-by: Aditya Garg <gargaditya08@live.com>\n> ---\n>  git-send-email.perl | 14 +++++++++++++-\n>  1 file changed, 13 insertions(+), 1 deletion(-)\n\nAs maildomain() is called at most once in a process, thanks to\nsend_message() conditionally calling it only to set $smtp_domain\nthat is not yet set, I do not personally mind adding an extra\nfork/exec here, but ...\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 55b7e00d29..735d8abc12 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1393,8 +1393,20 @@ sub maildomain_mta {\n>  \treturn $maildomain;\n>  }\n>  \n> +sub maildomain_hostname_command {\n> +\tmy $maildomain;\n> +\n> +\tif ($^O eq 'linux' || $^O eq 'darwin') {\n> +\t\tmy $domain = `(hostname --fqdn) 2>/dev/null`;\n> +\t\tchomp($domain);\n> +\t\t$maildomain = $domain if valid_fqdn($domain);\n\n... we do not know everybody's implementation, especially including\nthe non stardard ones, of 'hostname --fqdn'.  Some may stay silent,\nor say something only to its standard error, when it cannot produce\na usable output, which is the above code expects, but some others\nemit whatever it wants to to its standard output while signalling an\nerror with its exit value, when it sees some error (like \"I do not\nknow about that 'fqdn' option\").\n\nIn short, I do not have too much trouble against the idea to add\n\"ask hostname(1)\" to the source of maildomain information, but I'd\nprefer for the implementation to be a bit more careful to detect\nerrors, more careful than \"if we get anything on its standard\noutput, it cannot be an error and we'd use that\".  I understand that\nthe call to \"if valid_fqdn()\" tightens the condition a bit better by\nlooking at $domain, but we shouldn't be even chomping $domain or\nfeeding it to valid_fqdn() when we know the `hostname` failed in the\nfirst place.\n\n> +\t}\n> +\treturn $maildomain;\n> +}\n\nThanks.\n"},{"id":"517725","messageId":"PN3PR01MB9597BC2E1B526A11D21BAB24B895A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597C419019DC28E489D2AF9B88AA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-10T07:37:13Z","receivedAt":"2025-05-10T07:38:40Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"`hostname` is a popular command available on both Linux and macOS. As\nper the man-page[1], `hostname --fqdn` command returns the fully\nqualified domain name (FQDN) of the system. The current Net::Domain\nperl module being used in the script for the same has been quite\nunrealiable in many cases. Thankfully, we now have a better check for\nvalid_fqdn, which does reject the invalid FQDNs given by this module\nproperly, but at the same time, it will result in a fallback to\n'localhost.localdomain' being used. `hostname --fqdn` has been quite\nreliable (probably even more reliable than the Net::Domain module) and\nbefore falling back to 'localhost.localdomain', we should try to use it.\nInterestingly, the `hostname` command is actually used by perl modules\nlike Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets\ngive `hostname --fqdn` a chance as well!\n\n[1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\nv2: Avoid chomping $domain and assigning it to $maildomain if the command fails.\n\n git-send-email.perl | 16 +++++++++++++++-\n 1 file changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 55b7e00d29..511f627ba6 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1393,8 +1393,22 @@ sub maildomain_mta {\n \treturn $maildomain;\n }\n \n+sub maildomain_hostname_command {\n+\tmy $maildomain;\n+\n+\tif ($^O eq 'linux' || $^O eq 'darwin') {\n+\t\tmy $domain = `(hostname --fqdn) 2>/dev/null`;\n+\t\tif (!$?) {\n+\t\t\tchomp($domain);\n+\t\t\t$maildomain = $domain if valid_fqdn($domain);\n+\t\t}\n+\t}\n+\treturn $maildomain;\n+}\n+\n sub maildomain {\n-\treturn maildomain_net() || maildomain_mta() || 'localhost.localdomain';\n+\treturn maildomain_net() || maildomain_mta() ||\n+\t\tmaildomain_hostname_command || 'localhost.localdomain';\n }\n \n sub smtp_host_string {\n-- \n2.49.0\n\n"},{"id":"517800","messageId":"D9U0KAX6KVXK.WCY7YGX2Q0A5@swagemakers.org","threadId":"63393","inReplyTo":"PN3PR01MB9597BC2E1B526A11D21BAB24B895A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Julian Swagemakers","fromEmail":"julian@swagemakers.org","sentAt":"2025-05-12T07:46:05Z","receivedAt":"2025-05-12T07:46:07Z","isPatch":true,"sender":{"key":"julian@swagemakers.org","avatar":"https://gravatar.com/avatar/61b8010bc77390da6713f1622e3276430152d11cd512c11c1c241716991a358b?d=mp&s=160"},"body":"On Sat May 10, 2025 at 9:37 AM CEST, Aditya Garg wrote:\n> `hostname` is a popular command available on both Linux and macOS. As\n> per the man-page[1], `hostname --fqdn` command returns the fully\n> qualified domain name (FQDN) of the system.\n\nThere are multiple implementations of the hostname command, and they\ndon't all support `--fqdn`. For example this will not work on Alpine\nLinux as well as macOS.\n\nmacOS:\n\n    $ hostname --fqdn\n    hostname: illegal option -- -\n    usage: hostname [-f] [-s | -d] [name-of-host]\n\nAlpine:\n\n    $ hostname --fqdn\n    hostname: unrecognized option: fqdn\n    BusyBox v1.37.0 (2025-01-17 18:12:01 UTC) multi-call binary.\n\n    Usage: hostname [-sidf] [HOSTNAME | -F FILE]\n\n    Show or set hostname or DNS domain name\n\n        -s\tShort\n        -i\tAddresses for the hostname\n        -d\tDNS domain name\n        -f\tFully qualified domain name\n        -F FILE\tUse FILE's content as hostname\n\nAll seem to support `-f` though, maybe that would be the better option.\n\nRegards Julian\n"},{"id":"517801","messageId":"PN3PR01MB959732CE8360446CD4E0A184B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"D9U0KAX6KVXK.WCY7YGX2Q0A5@swagemakers.org","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-12T07:49:35Z","receivedAt":"2025-05-12T07:49:40Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 12 May 2025, at 1:16 PM, Julian Swagemakers <julian@swagemakers.org> wrote:\n> \n> ﻿On Sat May 10, 2025 at 9:37 AM CEST, Aditya Garg wrote:\n>> `hostname` is a popular command available on both Linux and macOS. As\n>> per the man-page[1], `hostname --fqdn` command returns the fully\n>> qualified domain name (FQDN) of the system.\n> \n> There are multiple implementations of the hostname command, and they\n> don't all support `--fqdn`. For example this will not work on Alpine\n> Linux as well as macOS.\n> \n> macOS:\n> \n>    $ hostname --fqdn\n>    hostname: illegal option -- -\n>    usage: hostname [-f] [-s | -d] [name-of-host]\n> \n> Alpine:\n> \n>    $ hostname --fqdn\n>    hostname: unrecognized option: fqdn\n>    BusyBox v1.37.0 (2025-01-17 18:12:01 UTC) multi-call binary.\n> \n>    Usage: hostname [-sidf] [HOSTNAME | -F FILE]\n> \n>    Show or set hostname or DNS domain name\n> \n>        -s    Short\n>        -i    Addresses for the hostname\n>        -d    DNS domain name\n>        -f    Fully qualified domain name\n>        -F FILE    Use FILE's content as hostname\n> \n> All seem to support `-f` though, maybe that would be the better option.\n\nSure. I was using -f before, but thought --fqdn would be more intuitive for\nanyone reading the code. Didn't know its not supported every where."},{"id":"517803","messageId":"PN3PR01MB959701F40F805351472EA4CCB897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597C419019DC28E489D2AF9B88AA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v3] send-email: try to get fqdn by running hostname -f on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-12T08:11:19Z","receivedAt":"2025-05-12T08:13:04Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"`hostname` is a popular command available on both Linux and macOS. As\nper the man-page[1], `hostname -f` command returns the fully qualified\ndomain name (FQDN) of the system. The current Net::Domain perl module\nbeing used in the script for the same has been quite unrealiable in many\ncases. Thankfully, we now have a better check for valid_fqdn, which does\nreject the invalid FQDNs given by this module properly, but at the same\ntime, it will result in a fallback to 'localhost.localdomain' being\nused. `hostname -f` has been quite reliable (probably even more reliable\nthan the Net::Domain module) and before falling back to\n'localhost.localdomain', we should try to use it. Interestingly, the\n`hostname` command is actually used by perl modules like Net::Domain[2]\nand Sys::Hostname[3] to get the hostname. So, lets give `hostname -f` a\nchance as well!\n\n[1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\nv2: Avoid chomping $domain and assigning it to $maildomain if the command fails.\nv3: Use `hostname -f` instead of `hostname --fqdn` since -f is supported everywhere.\n\n git-send-email.perl | 16 +++++++++++++++-\n 1 file changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 55b7e00d29..659e6c588b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1393,8 +1393,22 @@ sub maildomain_mta {\n \treturn $maildomain;\n }\n \n+sub maildomain_hostname_command {\n+\tmy $maildomain;\n+\n+\tif ($^O eq 'linux' || $^O eq 'darwin') {\n+\t\tmy $domain = `(hostname -f) 2>/dev/null`;\n+\t\tif (!$?) {\n+\t\t\tchomp($domain);\n+\t\t\t$maildomain = $domain if valid_fqdn($domain);\n+\t\t}\n+\t}\n+\treturn $maildomain;\n+}\n+\n sub maildomain {\n-\treturn maildomain_net() || maildomain_mta() || 'localhost.localdomain';\n+\treturn maildomain_net() || maildomain_mta() ||\n+\t\tmaildomain_hostname_command || 'localhost.localdomain';\n }\n \n sub smtp_host_string {\n-- \n2.49.0\n\n"},{"id":"517844","messageId":"xmqqtt5qvtt3.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597BC2E1B526A11D21BAB24B895A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-12T13:32:08Z","receivedAt":"2025-05-12T13:32:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n> `hostname` is a popular command available on both Linux and macOS. As\n> per the man-page[1], `hostname --fqdn` command returns the fully\n> qualified domain name (FQDN) of the system. The current Net::Domain\n> perl module being used in the script for the same has been quite\n> unrealiable in many cases. Thankfully, we now have a better check for\n> valid_fqdn, which does reject the invalid FQDNs given by this module\n> properly, but at the same time, it will result in a fallback to\n> 'localhost.localdomain' being used. `hostname --fqdn` has been quite\n> reliable (probably even more reliable than the Net::Domain module) and\n> before falling back to 'localhost.localdomain', we should try to use it.\n> Interestingly, the `hostname` command is actually used by perl modules\n> like Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets\n> give `hostname --fqdn` a chance as well!\n>\n> [1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n> [2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n> [3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n>\n> Signed-off-by: Aditya Garg <gargaditya08@live.com>\n> ---\n> v2: Avoid chomping $domain and assigning it to $maildomain if the command fails.\n>\n>  git-send-email.perl | 16 +++++++++++++++-\n>  1 file changed, 15 insertions(+), 1 deletion(-)\n\nLooks sensible. Will queue. Thanks.\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 55b7e00d29..511f627ba6 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1393,8 +1393,22 @@ sub maildomain_mta {\n>  \treturn $maildomain;\n>  }\n>  \n> +sub maildomain_hostname_command {\n> +\tmy $maildomain;\n> +\n> +\tif ($^O eq 'linux' || $^O eq 'darwin') {\n> +\t\tmy $domain = `(hostname --fqdn) 2>/dev/null`;\n> +\t\tif (!$?) {\n> +\t\t\tchomp($domain);\n> +\t\t\t$maildomain = $domain if valid_fqdn($domain);\n> +\t\t}\n> +\t}\n> +\treturn $maildomain;\n> +}\n> +\n>  sub maildomain {\n> -\treturn maildomain_net() || maildomain_mta() || 'localhost.localdomain';\n> +\treturn maildomain_net() || maildomain_mta() ||\n> +\t\tmaildomain_hostname_command || 'localhost.localdomain';\n>  }\n>  \n>  sub smtp_host_string {\n"},{"id":"517868","messageId":"xmqqa57hvl0f.fsf@gitster.g","threadId":"63393","inReplyTo":"D9U0KAX6KVXK.WCY7YGX2Q0A5@swagemakers.org","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-12T16:42:08Z","receivedAt":"2025-05-12T16:42:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Julian Swagemakers\" <julian@swagemakers.org> writes:\n\n> There are multiple implementations of the hostname command, and they\n> don't all support `--fqdn`. For example this will not work on Alpine\n> Linux as well as macOS.\n> ...\n> All seem to support `-f` though, maybe that would be the better option.\n\nWhat makes me worried about such a proposed changes is if there are\nimplementations that takes `-f` but uses it to mean something\ncompletely different from fqdn, and emits something that looks like\na hostname but is not.  At least an implementation that takes --fqdn\nwithout erroring out would try to give what this code wants to find\nout (or it is simply crazy), but -f does not feel specific enough.\n"},{"id":"517871","messageId":"PN3PR01MB9597D7CAABB0EEE93A5CC490B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqqa57hvl0f.fsf@gitster.g","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-12T16:46:41Z","receivedAt":"2025-05-12T16:46:46Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 12 May 2025, at 10:12 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿\"Julian Swagemakers\" <julian@swagemakers.org> writes:\n> \n>> There are multiple implementations of the hostname command, and they\n>> don't all support `--fqdn`. For example this will not work on Alpine\n>> Linux as well as macOS.\n>> ...\n>> All seem to support `-f` though, maybe that would be the better option.\n> \n> What makes me worried about such a proposed changes is if there are\n> implementations that takes `-f` but uses it to mean something\n> completely different from fqdn, and emits something that looks like\n> a hostname but is not.  At least an implementation that takes --fqdn\n> without erroring out would try to give what this code wants to find\n> out (or it is simply crazy), but -f does not feel specific enough.\n\nWhat we can do is use `hostname -f` for macOS, after all its the only darwin based\nOS used rn, and use hostname --fqdn for Linux.\n\nAlthough it still leaves out Alpine Linux."},{"id":"517879","messageId":"PN3PR01MB959755FD34845EC9026EFAA7B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"PN3PR01MB9597C419019DC28E489D2AF9B88AA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"[PATCH v4] send-email: try to get fqdn by running hostname -f on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-12T17:16:48Z","receivedAt":"2025-05-12T17:18:46Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"`hostname` is a popular command available on both Linux and macOS. As\nper the man-page[1], `hostname -f` command returns the fully qualified\ndomain name (FQDN) of the system. The current Net::Domain perl module\nbeing used in the script for the same has been quite unrealiable in many\ncases. Thankfully, we now have a better check for valid_fqdn, which does\nreject the invalid FQDNs given by this module properly, but at the same\ntime, it will result in a fallback to 'localhost.localdomain' being\nused. `hostname -f` has been quite reliable (probably even more reliable\nthan the Net::Domain module) and before falling back to\n'localhost.localdomain', we should try to use it.\n\nIn this patch we shall be using `hostname --fqdn` command on Linux\ninstead of `hostname -f`. This is because `hostname -f` could output\nsomething else in case a Linux distro uses some other implementation of\n`hostname`. On the other hand, `hostname --fqdn` is not valid on macOS,\nso we shall be using `hostname -f` there.\n\nInterestingly, the `hostname` command is actually used by perl modules\nlike Net::Domain[2] and Sys::Hostname[3] to get the hostname. So, lets\ngive `hostname -f` a chance as well!\n\n[1]: https://man7.org/linux/man-pages/man1/hostname.1.html\n[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88\n[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93\n\nSigned-off-by: Aditya Garg <gargaditya08@live.com>\n---\nv2: Avoid chomping $domain and assigning it to $maildomain if the command fails.\nv3: Use `hostname -f` instead of `hostname --fqdn` since -f is supported everywhere.\nv4: Use `hostname --fqdn` on Linux and `hostname -f` on macOS.\n\n git-send-email.perl | 18 +++++++++++++++++-\n 1 file changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 55b7e00d29..bdbc7f8149 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1393,8 +1393,24 @@ sub maildomain_mta {\n \treturn $maildomain;\n }\n \n+sub maildomain_hostname_command {\n+\tmy $maildomain;\n+\n+\tif ($^O eq 'linux' || $^O eq 'darwin') {\n+\t\tmy $domain = ($^O eq 'darwin') ?\n+\t\t\t`(hostname -f) 2>/dev/null` :\n+\t\t\t`(hostname --fqdn) 2>/dev/null`;\n+\t\tif (!$?) {\n+\t\t\tchomp($domain);\n+\t\t\t$maildomain = $domain if valid_fqdn($domain);\n+\t\t}\n+\t}\n+\treturn $maildomain;\n+}\n+\n sub maildomain {\n-\treturn maildomain_net() || maildomain_mta() || 'localhost.localdomain';\n+\treturn maildomain_net() || maildomain_mta() ||\n+\t\tmaildomain_hostname_command || 'localhost.localdomain';\n }\n \n sub smtp_host_string {\n-- \n2.49.0\n\n"},{"id":"517881","messageId":"xmqq5xi5u401.fsf@gitster.g","threadId":"63393","inReplyTo":"PN3PR01MB9597D7CAABB0EEE93A5CC490B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-12T17:34:54Z","receivedAt":"2025-05-12T17:34:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Aditya Garg <gargaditya08@live.com> writes:\n\n>> On 12 May 2025, at 10:12 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> \n>> ﻿\"Julian Swagemakers\" <julian@swagemakers.org> writes:\n>> \n>>> There are multiple implementations of the hostname command, and they\n>>> don't all support `--fqdn`. For example this will not work on Alpine\n>>> Linux as well as macOS.\n>>> ...\n>>> All seem to support `-f` though, maybe that would be the better option.\n>> \n>> What makes me worried about such a proposed changes is if there are\n>> implementations that takes `-f` but uses it to mean something\n>> completely different from fqdn, and emits something that looks like\n>> a hostname but is not.  At least an implementation that takes --fqdn\n>> without erroring out would try to give what this code wants to find\n>> out (or it is simply crazy), but -f does not feel specific enough.\n>\n> What we can do is use `hostname -f` for macOS, after all its the only darwin based\n> OS used rn, and use hostname --fqdn for Linux.\n>\n> Although it still leaves out Alpine Linux.\n\nAs long as we record the reasoning behind our decision to use `-f`,\nwith an explanation like \"we can add a configuration to disable this\nif an odd platform implementation of `hostname -f` truly misbehaves\"\nto suggest that we can, if needed, easily give an escape hatch if\nthis change breaks existing users, I think it is OK to just use\n`-f`, which would be the simplest ;-)\n\nThanks.\n"},{"id":"517887","messageId":"PN3PR01MB9597413F0653AE9DDBC282B9B897A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqq5xi5u401.fsf@gitster.g","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-12T17:42:15Z","receivedAt":"2025-05-12T17:42:20Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 12 May 2025, at 11:05 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Aditya Garg <gargaditya08@live.com> writes:\n> \n>>>> On 12 May 2025, at 10:12 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> \n>>> ﻿\"Julian Swagemakers\" <julian@swagemakers.org> writes:\n>>> \n>>>> There are multiple implementations of the hostname command, and they\n>>>> don't all support `--fqdn`. For example this will not work on Alpine\n>>>> Linux as well as macOS.\n>>>> ...\n>>>> All seem to support `-f` though, maybe that would be the better option.\n>>> \n>>> What makes me worried about such a proposed changes is if there are\n>>> implementations that takes `-f` but uses it to mean something\n>>> completely different from fqdn, and emits something that looks like\n>>> a hostname but is not.  At least an implementation that takes --fqdn\n>>> without erroring out would try to give what this code wants to find\n>>> out (or it is simply crazy), but -f does not feel specific enough.\n>> \n>> What we can do is use `hostname -f` for macOS, after all its the only darwin based\n>> OS used rn, and use hostname --fqdn for Linux.\n>> \n>> Although it still leaves out Alpine Linux.\n> \n> As long as we record the reasoning behind our decision to use `-f`,\n> with an explanation like \"we can add a configuration to disable this\n> if an odd platform implementation of `hostname -f` truly misbehaves\"\n> to suggest that we can, if needed, easily give an escape hatch if\n> this change breaks existing users, I think it is OK to just use\n> `-f`, which would be the simplest ;-)\n\nI thinks its best to use --fqdn if its supported on most Linux distros and\n-f on macOS. It's not really possible for me to check the result of -f on\nall Linux distros. Although, we still have valid_fqdn checks in place which\nshould cover up most errors, and as far as I have noticed, distros supporting\n\n--fqdn support -f as an alternative.\n\nTbh, your call. The v3 of this patch has hostname -f and v4 has hostname --fqdn\nfor Linux and -f for macOS."},{"id":"517908","messageId":"CAPig+cQCpWhJoouuzZu9HPy7Fj-T5RcNnAqryxQ=ATn37Os49Q@mail.gmail.com","threadId":"63393","inReplyTo":"xmqq5xi5u401.fsf@gitster.g","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-05-12T19:05:37Z","receivedAt":"2025-05-12T19:05:51Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, May 12, 2025 at 1:34 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Aditya Garg <gargaditya08@live.com> writes:\n> >> On 12 May 2025, at 10:12 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> >> ﻿\"Julian Swagemakers\" <julian@swagemakers.org> writes:\n> >>> There are multiple implementations of the hostname command, and they\n> >>> don't all support `--fqdn`. For example this will not work on Alpine\n> >>> Linux as well as macOS.\n> >>> ...\n> >>> All seem to support `-f` though, maybe that would be the better option.\n> >>\n> >> What makes me worried about such a proposed changes is if there are\n> >> implementations that takes `-f` but uses it to mean something\n> >> completely different from fqdn, and emits something that looks like\n> >> a hostname but is not.  At least an implementation that takes --fqdn\n> >> without erroring out would try to give what this code wants to find\n> >> out (or it is simply crazy), but -f does not feel specific enough.\n> >\n> > What we can do is use `hostname -f` for macOS, after all its the only darwin based\n> > OS used rn, and use hostname --fqdn for Linux.\n> >\n> > Although it still leaves out Alpine Linux.\n>\n> As long as we record the reasoning behind our decision to use `-f`,\n> with an explanation like \"we can add a configuration to disable this\n> if an odd platform implementation of `hostname -f` truly misbehaves\"\n> to suggest that we can, if needed, easily give an escape hatch if\n> this change breaks existing users, I think it is OK to just use\n> `-f`, which would be the simplest ;-)\n\nThe problem is not restricted only to macOS (and Alpine), but more\ngenerally to all BSD-lineage `hostname` which does not understand\n--fqdn but does understand -f.\n"},{"id":"517910","messageId":"xmqq1pstsi02.fsf@gitster.g","threadId":"63393","inReplyTo":"CAPig+cQCpWhJoouuzZu9HPy7Fj-T5RcNnAqryxQ=ATn37Os49Q@mail.gmail.com","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-12T20:15:25Z","receivedAt":"2025-05-12T20:15:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> The problem is not restricted only to macOS (and Alpine), but more\n> generally to all BSD-lineage `hostname` which does not understand\n> --fqdn but does understand -f.\n\nTrue, but the proposed patch limits itself to \n\n      $^O eq 'linux' || $^O eq 'darwin'\n\nfor unfathomable reason, so BSD's are safe already ;-)\n"},{"id":"517942","messageId":"PN3PR01MB9597CC4D8DB6946BEE9B0FB4B896A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM","threadId":"63393","inReplyTo":"xmqq1pstsi02.fsf@gitster.g","subject":"Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS","fromName":"Aditya Garg","fromEmail":"gargaditya08@live.com","sentAt":"2025-05-13T12:28:46Z","receivedAt":"2025-05-13T12:28:51Z","isPatch":true,"sender":{"key":"gargaditya08@live.com","avatar":"https://avatars.githubusercontent.com/u/85610623?v=4"},"body":"\n\n> On 13 May 2025, at 1:45 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> ﻿Eric Sunshine <sunshine@sunshineco.com> writes:\n> \n>> The problem is not restricted only to macOS (and Alpine), but more\n>> generally to all BSD-lineage `hostname` which does not understand\n>> --fqdn but does understand -f.\n> \n> True, but the proposed patch limits itself to\n> \n>      $^O eq 'linux' || $^O eq 'darwin'\n> \n> for unfathomable reason, so BSD's are safe already ;-)\n\nExactly. I had tested hostname -f on both macOS and Linux, but was lazy\nenough to not check --fqdn, thus resulting in a wrong patch. v3 and v4 should\nwork properly. I'll also avoid laziness in the future."}]}