Code Monkey home page Code Monkey logo

smtpapi-php's Introduction

Twilio SendGrid Logo

BuildStatus Latest Stable Version Latest Version on Packagist Twitter Follow GitHub contributors MIT licensed

This module helps build Twilio SendGrid's SMTP API headers.

Learn more about the SMTP API at Twilio SendGrid's documentation.

Announcements

All the updates to this module are documented in our CHANGELOG.

Table of Contents

Installation

Prerequisites

  • PHP version 7.3, 7.4, 8.0, or 8.1
  • The Twilio SendGrid service, starting at the free level

Install with Composer

The following recommended installation requires composer.

Add the following to your composer.json file.

{
    "require": {
        "sendgrid/smtpapi": "^0.7.0"
    }
}

Then at the top of your script require the autoloader:

require 'vendor/autoload.php';

Alternative: Install package from zip

If you are not using Composer, simply download and install the latest packaged release of the library as a zip.

⬇︎ Download Packaged Library ⬇︎

Then require the library from package:

require('path/to/smtpapi-php/smtpapi-php.php');

The previous versions of the library can be downloaded directly from GitHub.

Setup Environment Variables

Environment Variable

Update the development environment with your SENDGRID_API_KEY, for example:

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

Quick Start

$header = new Smtpapi\Header();
$header->addTo('[email protected]');
$header->addTo('[email protected]');
print $header->jsonString();

Usage

How to Contribute

We encourage contributions to our projects; please see our CONTRIBUTING guide for details.

Quick links:

About

smtpapi-php is maintained and funded by Twilio SendGrid, Inc. The names and logos for smtpapi-php are trademarks of Twilio SendGrid, Inc.

Support

If you need help using SendGrid, please check the Twilio SendGrid Support Help Center.

License

The MIT License (MIT)

smtpapi-php's People

Contributors

awwa avatar eddiezane avatar eddytan avatar eshanholtz avatar fishnux avatar gr8shivam avatar jennifermah avatar jmauerhan avatar motdotla avatar mptap avatar mtroiani avatar nikoskip avatar nocategory avatar nquinlan avatar owenvoke avatar pangaunn avatar pulse00 avatar pushkyn avatar rakatyal avatar saputradharma avatar sierzput avatar ssiddhantsharma avatar steptan avatar tariq1890 avatar thepriefy avatar thinkingserious avatar twilio-ci avatar twilio-dx avatar vinayak42 avatar yashasingh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smtpapi-php's Issues

Dockerize smtpapi-php

Issue Summary

It is really nice to be able to develop locally inside a docker container! Please dockerize this repo!

  • Please setup docker-compose to use a local volume for the library files
  • Please add information to the README and USAGE files about how to startup the container

Create a Use Cases Directory

Due to the success we have seen from hacktoberfest, we are seeing more people create use cases. This is amazing!
We want to make sure that everyone can find them. Please help us to break up this file and make it easier to read and manage:

  • Create a Use Cases Directory
  • Put a README.md in this directory
  • Make a file in the new directory for each individual Use Case from USE_CASES.md, copy the content to this file
  • For each file you've created, link to it from the README you created
  • Organize the links in the README by type
  • Make sure the names of the files you created are related to the Use Case
    Thank you!

Implement auto-deploy to package manager

Issue Summary

When all tests on the master branch pass in Travis CI, we would like to auto-deploy the release to the package manager.

Before writing any code, we suggest you review our CONTRIBUTING.md file and propose your solution for discussion here in the comments. Thank you!

Aceptance Criteria

  • when Travis CI passes all tests on the master branch we auto-deploy to the package manager
  • the version is determined by the CHANGELOG.md

Add a USE_CASES.md to this repo

It would be awesome to highlight some of the features of this library in a USE_CASES document.

Some examples that would be great:

  • How to send substitutions
  • How to send to multiple people in the To field
  • How to send multiple emails to multiple distinct addresses
  • How to schedule an email

Word-wrap the smtpapi-header before 998 chars

The string from jsonString function needs to be word-wrapped to work in all situations (also with SMTP, not only with HTTP).

The standards document for the format of e-mail messages, RFC 2822 (the successor to RFC 822, the classic document that established the standards that have been followed ever since), says this about the length of lines in an e-mail message: Line length SHOULD be less than 78 characters and MUST be 998 or less, including CRLF.

Example when using Postfix relay server, longer lines (than 998) are broken by inserting "CR + LF + SPACE", to minimize the damage to MIME formatted mail. Many times this breaks the smtpapi-header json and email SendGrid returns "Invalid SMTPAPI Header" -email notification. Error messages are hard to track down since the error can come up pretty much anywhere in the smtpapi-header.

Might be good idea to implement the word-wrapping near 1000 chars since the smtpapi-header can be really big sometimes if you use lots of substitution tags like I do. Also the word-wrapping needs to happen after tags like "]," to keep the json valid.

How Can I set unsubscribe link while sending email via API

How add it unsubscribe url in email body
`$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sendgrid.com/v3/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{"title":"March Newsletter","subject":"New Products for Spring!","sender_id":875149,"list_ids":[4375245],"segment_ids":[123124],"categories":["spring line"],"custom_unsubscribe_url":"http:://TestUrl/unsubscribe","html_content":"<title></title>

Check out follow this link to be removedunsubscribe instantly

","plain_content":"Check out our spring line!"}",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer MySendGridKey",
"content-type: application/json"
),
));`

Please help me

Auto-generate the CHANGELOG.md file upon release

Issue Summary

For every release, we currently hand craft a CHANGELOG.md update, now we would like to automate this process. Please see the existing CHANGELOG.md for formatting structure.

Acceptance Criteria

  • A script, which when run, creates a CHANGELOG.md update based on any merged PRs since the last release.

Add a USAGE.md file to this repo

As noted in #38 we're missing a USAGE file.

Please add a basic USAGE file to this repo that explains the basics of how to get started with SMTPAPI using this PHP library.

You can see an extensive example of this in the sendgrid-php library.

Add Table of Contents to README

As noted in #38, we're missing a Table of contents in the README file!

Please add in-page anchors to the headers, then add those links to a ToC at the top of the README. Please, see how these were updated to use "-" instead of "_" in #38.

Auto-generate the release notes upon release

Issue Summary

For every release, we hand craft the release notes on GitHub, now we would like to automate this process. Please see the existing release notes for an example. The contents of the release notes are generated from the CHANGELOG.md file. Here is the documentation for updating the release notes via the GitHub API.

Acceptance Criteria

  • A script, which when run, creates a release note update based on the last deployed release

How Can I set unsubscribe link while sending email via API

Issue Summary

Basically I would like to set a unsubscribe link under custom text while sending email via API.
Text would be "follow this link to be removed" (on this I want to set unsubscribe link).

I have enabled Subscription Tracking function from panel which displays unsubscribe link but I want to have my own link which I can place where I want.

I tried following combinations to set link

  1. <% follow this link to be removed %>
  2. < a href="[Unsubscribe]">follow this link to be removed < / a > (ignore white space around tag)
  3. < a href="[unsubscribe]">follow this link to be removed< / a > (ignore white space around tag)
  4. <%asm_preferences_url%>

Code

$sendgrid = new SendGrid('API-KEY');

$email = new SendGrid\Email();
$email->setSmtpapiTos($strArray)
->setFrom($eml['from_email'])
->setFromName($eml['from_name'])
->setSubject($sub)
->setHtml($nl_html)
->setSubstitutions(array('[%email%]' => $strArray));

$result = $sendgrid->send($email);

I have chat with support team but they do not have necessary resources to provide this level of analysis.
What am I missing here, or do I have to set any additional setting from my panel?

Technical

  • sendgrid-php Version: master
  • PHP Version: 5.x

Question: is the line-wrapping missing?

In the documentation it says that lines should be wrapped:

Headers must be wrapped to keep the line length under 72. By RFC 821 no line can be longer than 1,000, so if you are going to generate this string yourself it is a good idea to make sure that you wrap it.

Is this missing here, or should it be done elsewhere?

Require conformance to style standards

Issue Summary

In the CONTRIBUTING.md file there is a section on Style Guidelines & Naming Conventions. Please review and implement a check in Travis CI. If there are any style errors, either fix or create a rule to exclude the error.

Before writing any code, we suggest you review our CONTRIBUTING.md file and propose your solution for discussion here in the comments. Thank you!

Aceptance Criteria

  • TravisCI checks that the code conforms to our Style Guidelines & Naming Conventions as defined in our CONTRIBUTING.md file
  • tests pass locally, in Travis CI and using Docker

Create first time contributor documentation

Issue Summary

Our open sourced documentation has a great first time contributor page that we wish to duplicate here.

Acceptance Criteria

  • We have a file in the root directory called first-timers.md or similar that helps a first time contributor make their first PR (please use our CONTRIBUTOR.md file for inspiration as well as this page)
  • We provide a link to tasks with the labels "difficulty: easy" and "status: help wanted" (example query) to all the repos listed here, please scroll to the bottom.

Add our Developer Experience Engineer career opportunity to the README

Issue Summary

The role of Developer Experience Engineer just became available and we want to announce it in the README. Here is the copy:

If you're a software engineer who is passionate about #DeveloperExperience and/or #OpenSource, this is an incredible opportunity to join our #DX team as a Developer Experience Engineer and work with @thinkingserious and @aroach! Tell your friends :)

Acceptance Criteria

  • The above announcement is added to the Announcements section of this README

Add unittest to check for specific repo files

This repo should have the following list of files included:

  • ./Docker or docker/Docker
  • ./docker-compose.yml or ./docker/docker-compose.yml
  • ./.env_sample
  • ./.gitignore
  • ./.travis.yml
  • ./.codeclimate.yml
  • ./CHANGELOG.md
  • ./CODE_OF_CONDUCT.md
  • ./CONTRIBUTING.md
  • ./.github/ISSUE_TEMPLATE
  • ./LICENSE.md
  • ./.github/PULL_REQUEST_TEMPLATE
  • ./README.md
  • ./TROUBLESHOOTING.md
  • ./USAGE.md
  • ./USE_CASES.md

This PR is only asking for tests of the existence of these files, if the files do not exist when you run the tests - do not worry about the tests not passing. We will identify this and create a new PR for the issue.
Thank you!

Document new Git workflow in CHANGELOG.md

Issue Summary

We want to update our git workflow to function more like Gitflow. We need to update the CONTRIBUTING.md file and PULL_REQUEST_TEMPLATE to direct contributors to fork/branch off the development branch and to merge their PRs with the development branch. Once this issue is complete, we will be creating the development branch and making that branch the default. This is part of a larger strategy to execute releases for this SDK on a predictable cadence.

Acceptance Criteria

  • Update CONTRIBUTING.md documentation, explaining the process of forking and branching off the development branch and submitting PRs agains the development branch.
  • Update PULL_REQUEST_TEMPLATE with the same addition to the CONTRIBUTING.md documentation.

Add/Update Badges on README

Similar to what was done on the SendGrid node README:

  • put the logo at the top of the list
  • Add License like so
  • make sure the other badges are available like so:
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

For the following, make sure the correct repo is linked!
For email notifications, you can change the "nodejs" to the language of this repo (e.g. java, python, ruby, php, csharp, go, etc)

[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-nodejs.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-nodejs)
[![Email Notifications Badge](https://dx.sendgrid.com/badge/nodejs)](https://dx.sendgrid.com/newsletter/nodejs)
[![npm](https://img.shields.io/npm/l/express.svg)]()
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-nodejs.svg)](https://github.com/sendgrid/sendgrid-nodejs/graphs/contributors)

Thank you and happy #Hacktoberfest!!

Why is Swift Mailer a dependency?

Hi!

I'm trying to update to version 0.6 but I can't because in my project I'm currently using Swift Mailer version 6 and this package needs Swift Mailer ^5.4.

Maybe needs to be a dev dependency instead a production one, considering that it's only being used on the examples scripts:

"require-dev": {
        "phpunit/phpunit": "3.7.*",
        "swiftmailer/swiftmailer": "^5.4"
}

Or maybe a suggest:

"suggest": {
        "swiftmailer/swiftmailer": "^5.4 - Needed to run the example scripts"
}

BTW, you might need to update the README.md to reflect the new version on "Install with Composer" section.

Cheers!

Add a USAGE.md file

Usage files are really nice when they exist in a repo, because it makes it really obvious where to look for information about how to use this tool. It can be frustrating when you expect this file to be there and it's not.
Please add a USAGE.md file, you can see an example of this
here

Please make sure you modify the file for this repo (hint: Most of this information should be in the README file)

Bug fix for addTo() recipients with commas in their name

sendgrid/vendor/sendgrid/smtpapi/lib/Smtpapi/Header.php

If there is a comma in the value of $name, addTo() will not escape or quote it, leading to a faulty To: header.

I recommend changing line 16 to:

$this->to[] = ($name ? '"' . preg_replace('{"}', '"', $name) . '" ' : $email);

Moved from sendgrid/sendgrid-php#101.

Need to investigate if still an issue.

Update .md files for SEO-ness

We received an awesome PR for #hacktoberfest on our ruby library
We would love to see the same thing on the README in this repo as well.
Please replace the "-" with "_" in README, CONTRIBUTING, USE_CASES, USAGE files.

Thanks and happy Hacktoberfest!!

Add a .codeclimate.yml file to this repo

It is possible to configure how CodeClimate looks at a repository.
These Docs explain how this is done. Please create an appropriate .codeclimate.yml for this repo. It should test the main language of the repo and run tests.

Hacktoberfest: SendGrid Current Status

SendGrid DX team current status:

  • Wow
  • OMG
  • THANK YOU

Hacktoberfest 2017 has completely blown us away. We have had over 900 pull requests from over 300 contributors all in the last 30 days. That is more PRs than we normally get in 2 years!
We are actively working to review, comment, and/or merge as many PRs as we possibly can as quickly as we can.

We are currently working on “intaking” all the PRs that have come in, oldest first (we have about 400 remaining to go through). We are making sure that each PR we review is one we have a chance of merging - there have been a couple spammy items that came through. Due to the massive influx of requests so far, @thinkingserious and @mbernier have been working nights and weekends all month just to keep up! We’re not even mad, this is amazing!

Hey, that’s great for you - but what about my shirt!

If you have signed the CLA before 11/1, but haven’t had a PR merged yet, do not despair! We know we are behind on even just commenting on every PR to show you that we received it (something we typically do). If you submitted a mergeable (non-spam, actually adds value to the project) PR during October 2017, we will grant access to this page to redeem your shirt, sticker, and hacker pin. Next year, we will be sure to communicate this information sooner. We are sorry for any confusion we have caused. We appreciate those of you who have reached out to find out what’s going on!

What can I do to help move things along?

Have you signed the CLA yet?
We can only merge items from contributors who signed the CLA

Can you help another contributor?
If you can identify potential problems, add suggestions, or even leave a comment with your review of another PR (Looks good to me! Or I approve this change), that would help us review those PRs much faster, making it easier to get to your PR.

Do you even write tests, friend?
If you see a place where we could have a test to validate a piece of functionality, add it in. We know We know! It’s just another PR we have to review and merge. You’re right, it is! However, the more tests we have, the earlier our CI tool can catch issues, saving us a review as well as back and forth time.

@bertuss, @ladhadha, @mptap, @pushkyn, @ssiddhantsharma, @thepriefy, @uppe-r, @yudhik11

Cannot build or test locally

Issue Summary

I wanted to work on a fix for an issue reported here, but I am unable to run the existing tests locally or in CI, due to a test for files which do not exist in the repo. There is a test which checks for two Dockerfiles, which are not part of the repo, and the instructions to build and test locally don't include any info on creating these files.

Steps to Reproduce

  1. Clone the repo
  2. composer install
  3. run the tests as instructed in the docs

Technical details:

  • smtpapi-php Version: master (latest commit: [729d8e8])
  • PHP Version: 5.6 and 7.0

Add a .env_sample file

Our preference is that users have an environment file when using the SendGrid API, because it is less likely that someone would commit their credentials to github.

Please make a couple changes:

  • make a .env_sample file that contains: export SENDGRID_API_KEY=''
  • make (or add) a .gitignore file and include .env
  • add instructions to the README file about how to copy .env_sample to .env and add the API Key

Add a unittest to check the license.md file date range

The end year in the license file should be "this year" and this should be checked on every run of the tests. If the end year is no correct, fail the test.
example:

Copyright (c) 2012-2016 SendGrid, Inc.
It is 2017, so this should be:
Copyright (c) 2012-2017 SendGrid, Inc.
and the test should fail.
--done

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.