René's URL Explorer Experiment


Title: Added feature to 'Send a Single Email to a Single Recipient' by dibyadas · Pull Request #316 · sendgrid/sendgrid-python · GitHub

Open Graph Title: Added feature to 'Send a Single Email to a Single Recipient' by dibyadas · Pull Request #316 · sendgrid/sendgrid-python

X Title: Added feature to 'Send a Single Email to a Single Recipient' by dibyadas · Pull Request #316 · sendgrid/sendgrid-python

Description: This PR deals with issue #224. Proposed API simplification for Python Sendgrid module A create_mail function has been added that helps to perform this. Usage example:- sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) from_email = Email("test@example.com") to_email = Email("test@example.com") subject = "Test Subject" plain_content = "In Python" html_content = " Testing " msg = create_mail(from_email,subject,to_email,plain_content,html_content) response = sg.send_mail(msg) print(response.status_code) print(response.body) # 202 b' ' Also, certain features have been added that increases abstraction of the module. Like, the SendGridMessage class. Usage example:- .... msg = SendGridMessage() msg.from_email = Email("test@example.com") msg.to_email = Email("test@example.com") msg.subject = "subject" msg.plain_text_content = "SendGrid Python" msg.html_content = "Something" response = sg.send_mail(msg) print(response.status_code) print(response.body) # 202 b' ' SendGridClient class for simplification Applications, that use this module, should not be bothered about the complexity of the client. Like, for example, sg.client.mail.send.post(request_body=mail.get()),where the api endpoint is dynamically built,is the feature of python_http_client. Also the exception thrown by the module whenever an status code other than 200 and 202 is returned is of the urllib HTTPError class. The applications, ideally ,should not be aware of the underlying implementations. The SendGridClient tries to achieve this by wrapping the SendGridAPIClient class. This class can also handle the urllib.HTTPError internally and raise a SendGridException based on the error. This will be more application friendly and a lot more informative. Usage example: msg = SendGridMessage() msg.from_email = from_email msg.to_email = to_email msg.subject = subject msg.plain_text_content = plain_content msg.html_content = html_content response = sg.send_mail(msg) print(response.status_code) print(response.body) This can be very useful for small applications that need not worry about the internal complexities. SendGridException for abstraction and simplification This error class has been integrated with SendGridClient class and can raise an SendGridException when a HTTPError is thrown by urllib Usage Example:- msg = SendGridMessage() msg.from_email = Email("test@example.com") msg.to_email = Email("test@example.com") msg.subject = "" # empty subject, v3 api returns 400 error msg.plain_text_content = "SendGrid Python" msg.html_content = "Something" try: response = sg.send_mail(msg) except SendGridException as e: print("exception handled by application") # exception is properly handled This SendGridException is currently very nascent, just for showing an example. Once approved, its functionalities will be increased and it will raise more informative errors, leveraging the rich response returned by v3 SendGrid API. This is open to suggestions for improvement. (P.S.- It seems , while rebasing, I mistakenly squashed my commit with @thinkingserious. I will try to correct it ASAP)

Open Graph Description: This PR deals with issue #224. Proposed API simplification for Python Sendgrid module A create_mail function has been added that helps to perform this. Usage example:- sg = sendgrid.SendGridAPICli...

X Description: This PR deals with issue #224. Proposed API simplification for Python Sendgrid module A create_mail function has been added that helps to perform this. Usage example:- sg = sendgrid.SendGridAPICli...

Opengraph URL: https://github.com/sendgrid/sendgrid-python/pull/316

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:7c48ed69-84f5-3f54-3774-fda6da2f818f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD49A:291B58:222AAB3:2B57332:6B01B508
html-safe-nonce34bcdf5dd72613cbc93ba789b85f5c34439e85fa91f69e8cc53f863871884b91
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDlBOjI5MUI1ODoyMjJBQUIzOjJCNTczMzI6NkIwMUI1MDgiLCJ2aXNpdG9yX2lkIjoiOTIwNjg5MTIwNTQ1ODI0NDg3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac316d626c11dcb167e8a7d7fb631eeefdee9d0756b0a1d7e919241ad7a23c0dcd
hovercard-subject-tagpull_request:121669037
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/sendgrid/sendgrid-python/pull/316/files
twitter:imagehttps://avatars.githubusercontent.com/u/21265801?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/21265801?s=400&v=4
og:image:altThis PR deals with issue #224. Proposed API simplification for Python Sendgrid module A create_mail function has been added that helps to perform this. Usage example:- sg = sendgrid.SendGridAPICli...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/sendgrid/sendgrid-python git https://github.com/sendgrid/sendgrid-python.git
octolytics-dimension-user_id181234
octolytics-dimension-user_loginsendgrid
octolytics-dimension-repository_id3546794
octolytics-dimension-repository_nwosendgrid/sendgrid-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3546794
octolytics-dimension-repository_network_root_nwosendgrid/sendgrid-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/sendgrid/sendgrid-python/pull/316/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsendgrid%2Fsendgrid-python%2Fpull%2F316%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsendgrid%2Fsendgrid-python%2Fpull%2F316%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=sendgrid%2Fsendgrid-python
Reloadhttps://github.com/sendgrid/sendgrid-python/pull/316/files
Reloadhttps://github.com/sendgrid/sendgrid-python/pull/316/files
Reloadhttps://github.com/sendgrid/sendgrid-python/pull/316/files
sendgridhttps://github.com/sendgrid
sendgrid-pythonhttps://github.com/sendgrid/sendgrid-python
Codehttps://github.com/sendgrid/sendgrid-python
Issues50 (50)https://github.com/sendgrid/sendgrid-python/issues
Pull requests17 (17)https://github.com/sendgrid/sendgrid-python/pulls
Actionshttps://github.com/sendgrid/sendgrid-python/actions
Security and qualityhttps://github.com/sendgrid/sendgrid-python/security
Insightshttps://github.com/sendgrid/sendgrid-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fsendgrid%2Fsendgrid-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsendgrid%2Fsendgrid-python%2Fissues%2Fnew%2Fchoose
dibyadashttps://github.com/dibyadas
sendgrid:masterhttps://github.com/sendgrid/sendgrid-python/tree/master
dibyadas:single_mailhttps://github.com/dibyadas/sendgrid-python/tree/single_mail
Conversation 34 https://github.com/sendgrid/sendgrid-python/pull/316
Commits 7 https://github.com/sendgrid/sendgrid-python/pull/316/commits
Checks 0 https://github.com/sendgrid/sendgrid-python/pull/316/checks
Files changed https://github.com/sendgrid/sendgrid-python/pull/316/files
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
Added feature to 'Send a Single Email to a Single Recipient' https://github.com/sendgrid/sendgrid-python/pull/316/files#top
Show all changes 7 commits https://github.com/sendgrid/sendgrid-python/pull/316/files
71a82cf Version Bump v4.1.0: Pull #314 Add ability to impersonate subuser thinkingserious May 9, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/71a82cf45ee92885787557ef0f300893d594cb77
bfd18e9 added support for creating single mail and declared custom exceptions dibyadas May 19, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/bfd18e92deee220318e4355c8136b0e79a79c899
e64d532 increased functionalities dibyadas May 20, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/e64d53231a743db888f848ab2b5154e88a29bbc0
71ff547 added test dibyadas May 21, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/71ff5470e21286ee85a95456e349b0ed6566d536
8ec85b6 used SendGridException to handle HTTPErrors dibyadas May 22, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/8ec85b6368dd7992df1bb571957b6cedf90bfb80
3dd7ef3 fix for python 2.7 & 2.6 dibyadas May 22, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/3dd7ef3695d68e8d7a18ab3d0973be6fe8b6ca0c
ac64ab9 Merge branch 'master' into single_mail thinkingserious Jun 7, 2017 https://github.com/sendgrid/sendgrid-python/pull/316/commits/ac64ab98b7ea1bd306c95957e301e3e5afe3175e
Clear filters https://github.com/sendgrid/sendgrid-python/pull/316/files
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
__init__.py https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-1ba4c40ab876c3cc2547cb290acaf5b89fb75960be6e459345c99a64df5eae39
exceptions.py https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-e69f506edbba8ad5d4d21670edce09d13ee8bcb95278ff1ec3cb716a94d79858
mail.py https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-4240b4e12e2bb0e5c9369c556938f5aab18e7ee3366f8e3107c93c96182615b9
test_mail.py https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
sendgrid/helpers/exceptions/__init__.pyhttps://github.com/sendgrid/sendgrid-python/pull/316/files#diff-1ba4c40ab876c3cc2547cb290acaf5b89fb75960be6e459345c99a64df5eae39
View file https://github.com/dibyadas/sendgrid-python/blob/ac64ab98b7ea1bd306c95957e301e3e5afe3175e/sendgrid/helpers/exceptions/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sendgrid/sendgrid-python/pull/316/{{ revealButtonHref }}
w-https://github.com/w-
May 22, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r117651983
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
dibyadashttps://github.com/dibyadas
May 22, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r117662305
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
sendgrid/helpers/exceptions/exceptions.pyhttps://github.com/sendgrid/sendgrid-python/pull/316/files#diff-e69f506edbba8ad5d4d21670edce09d13ee8bcb95278ff1ec3cb716a94d79858
View file https://github.com/dibyadas/sendgrid-python/blob/ac64ab98b7ea1bd306c95957e301e3e5afe3175e/sendgrid/helpers/exceptions/exceptions.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sendgrid/sendgrid-python/pull/316/{{ revealButtonHref }}
w-https://github.com/w-
May 22, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r117652018
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
dibyadashttps://github.com/dibyadas
May 22, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r117662527
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
thinkingserioushttps://github.com/thinkingserious
May 22, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r117843640
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://github.com/sendgrid/sendgrid-python/blob/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7/sendgrid/exceptions.pyhttps://github.com/sendgrid/sendgrid-python/blob/0942f9de2d5ba5fedb65a23940ebe1005a21a6c7/sendgrid/exceptions.py
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
sendgrid/helpers/mail/mail.pyhttps://github.com/sendgrid/sendgrid-python/pull/316/files#diff-4240b4e12e2bb0e5c9369c556938f5aab18e7ee3366f8e3107c93c96182615b9
View file https://github.com/dibyadas/sendgrid-python/blob/ac64ab98b7ea1bd306c95957e301e3e5afe3175e/sendgrid/helpers/mail/mail.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sendgrid/sendgrid-python/pull/316/{{ revealButtonHref }}
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-4240b4e12e2bb0e5c9369c556938f5aab18e7ee3366f8e3107c93c96182615b9
thinkingserioushttps://github.com/thinkingserious
May 26, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r118746598
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
dibyadashttps://github.com/dibyadas
May 27, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r118814787
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
thinkingserioushttps://github.com/thinkingserious
May 27, 2017https://github.com/sendgrid/sendgrid-python/pull/316/files#r118829295
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
herehttps://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/Helpers/Mail/SendGridMessage.cs#L1464
Please reload this pagehttps://github.com/sendgrid/sendgrid-python/pull/316/files
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-4240b4e12e2bb0e5c9369c556938f5aab18e7ee3366f8e3107c93c96182615b9
test/test_mail.pyhttps://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
View file https://github.com/dibyadas/sendgrid-python/blob/ac64ab98b7ea1bd306c95957e301e3e5afe3175e/test/test_mail.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/sendgrid/sendgrid-python/pull/316/{{ revealButtonHref }}
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
https://github.com/sendgrid/sendgrid-python/pull/316/files#diff-67177a8d94c7cded0a163a6557ad5d886bffeb8fa025929bfd5e4e0218f6f168
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.