PHP Form Builder Class / Examples / Email w/PHPMailer + Google's Gmail Service

Version: Released:

Email w/Google's Gmail Service - This project's email function provides the ability to email a form's submitted data using PHPMailer and Google's Gmail service. This function has four parameters as seen below.

Before getting started, you'll want to review the checklist of information provided below to ensure you have a good understanding on how this functionality works.

  1. You'll need a Google Gmail account. If you don't have one, you can create one by clicking the "Create an account" link at http://mail.google.com.
  2. to, replyto, cc, and bcc can contain multiple email addresses - just separate them with commas.
  3. to, from, replyto, cc, bcc can contain email addresses formatted as either "my@email.com" or "My Email <my@email.com>"
  4. Within the email function, a call is made to another public function - getEmail - to get the email's html/text content. If you already have an existing system in place for sending email, you can use this function instead of the project's email function to build a string containing an html/text representation of the form's submitted data. By default, this function will return html, but you can pass true as the first and only parameter to return text.

In the php source code of this example file, you'll see that the email function call currently contains demo authentication/email settings ("my_email", "my_password", etc). You'll want to replace these with your information. Another important thing to note is that the various email settings that can be applied through the email function's fourth parameter are optional. In the php source code of this example file, you'll find all of them listed for reference in the email function call. Feel free to include as many or few as needed.

Processing