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.
- Google Account Email Address - Email address (including domain) of your Google Gmail account.
- Google Account Password - Password of your Google Gmail account.
- Additional Parameters (optional) - This parameter allows you to set various email settings through an associative array of key/value pairs. Available settings are provided below.
- to - Sets the email's to address. If blank, this parameter will be set to the Google Gmail account email address used in the first parameter.
- subject - Sets the email's subject.
- from - Sets the email's from address. If blank, this parameter will be set to the Google Gmail account email address used in the first parameter.
- replyto - Sets the email's reply to address. If empty, the from address will be used.
- cc - Sets the email's CC address.
- bcc - Sets the email's BCC address.
- preHTML - Allows you to prepend html content above the form's submitted data.
- postHTML - Allows you to append html content below the form's submitted data.
- textonly - Sends text-only version of the form's submitted data. By default, the email function will send an email containing both an html and text version.
- css - Gives you the ability to style the html email as needed. This parameter should be passed as a string beginning with <style type="text/css"> and ending with </style>
- cssFile - Gives you the ability to style the html email as needed by specifying a css include file.
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.
- 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.
- to, replyto, cc, and bcc can contain multiple email addresses - just separate them with commas.
- to, from, replyto, cc, bcc can contain email addresses formatted as either "my@email.com" or "My Email <my@email.com>"
- 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.