24/7 U.S. Support – 877-595-4482
This walkthrough will assist in sending emails through phpMailer and is intended for webmasters who are familiar with php.
First, download phpMailer using our direct download link here:
In this example, we will be referring to a basic form such as the following. Notice that the action is set to email.php
Our email.php script, which will process the form data and send the email, will need to include the class.phpmailer.php file:
Note that the require path should reflect the location of the phpmailer.php file. Now, your actual mailing script in this case would end up looking like my example below:
Here is more detail on much of the code above:
This tells the script that the method of sending is SMTP
$mail->Host = "localhost";
This is the hostname of the mail server being used. If you are sending from our server, this can be localhost or mail.yourdomain.com
$mail->From = "
The email address that the mail will appear to be from. This does not have to match your SMTP username, but must be a valid email address.
$mail->FromName = "Your Name";
The name that will appear as the sender of the email
Who will be receiving the form results. You can add as many recipients as you want simply by duplicating this line in the script.
$mail->SMTPAuth = "true";
This tells the script to use SMTP authentication, which is required to send mail through our servers.
$mail->Username = "your@emailaddress";
These are your login credentials for SMTP, which should reflect a valid email username and password. If this is an account you set up from your cPanel, your username will be your entire email address.
$mail->Subject = "Feedback form results";
This is the subject line of the email that will be sent.
$mail->Body = $message;
For the message body, you will need to rename $message with the variable that you created in your HTML form for the message field.
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
Now when you send an email using the form, the form will use SMTP the same as an email client would. For a listing of the optional variables that you can add, you should read the documentation: http://phpmailer.sourceforge.net/docs/
|Email:||support@WebHostingHub.com||Ticket:||Submit a Support Ticket|
|Chat:||Click To Chat Now|