vps

How To Send Email Using PHP

With GPD Host Web Hosting Services, the default PHP mail function is disabled in order to control spam. However, users of GPDHost can send emails from the server using SMTP authentication, as mentioned below. For widely used CMS applications like WordPress, Cake, (and others) a number of modules are available to use for managing and sending emails.

Simple Mail Transmission Protocol (SMTP)

Email is considered one of the most valuable and widely used services on the internet. However, it can often be complicated to transfer one inbox to another. If you need to transfer your emails, you should get familiarized with Simple Mail Transmission Protocol (or SMTP). SMTP is the most universally used tool for transferring emails from one user to another.It does not matter what kind of email account you have; SMTP will be used whether it’s a personal or business related email. While SMTP is a push protocol used to send the emails, there are two protocols: POP (post office protocol) or IMAP (internet message access protocol) that enable the receiver to retrieve the emails.There are two types of SMTP:
1. End-to-end method
2. Store-and-forward method

The first method (end-to-end) is used for communication between organizations or businesses. Meanwhile, the second one (store-and-forward) is used for internal communications within the same organization or business.

How To Setup SMTP

SMTP server (i.e., outgoing mail): smtp.gmail.com
SMTP username: Your full Gmail, Google Apps email address
SMTP password: Your Gmail or Google Apps email password
SMTP port: 465
SMTP TLS/SSL required: yes

In order to store a copy of outgoing emails in your Gmail or Google Apps Sent folder: First, log into your Gmail or Google Apps email Settings and click on the Forwarding/IMAP tab.
Then, scroll down to the IMAP Access section; IMAP must be enabled in order for emails to be properly copied to your sent folder.

If you are receiving an error message, you have to enable your Gmail to allow less secure apps by following these links.
https://myaccount.google.com/lesssecureapps
https://accounts.google.com/DisplayUnlockCaptcha

vps
vps

How To Add PHPMailer Code To Your Site

Download PHP mail class from GitHub https://github.com/PHPMailer/PHPMailer. Then, extract and upload the file to the server by using FTP.

?php
require("class.PHPMailer.php"); //include path accordingly.
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.example.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from@example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@example.net", "Josh Adams");
$mail->AddAddress("ellen@example.com"); // name is optional
$mail->AddReplyTo("info@example.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body in bold!";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent.

";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?

HOW TO CREATE WEBSITE ON WORDPRESS

GPD Host Contacts
  • Address: 375 Pearl St,
    New York, NY 10038
  • Phone: +1 718 975 7576
  • Chat with GPD
GPD Host Social
Pay with Confidence

Copyright © 2017 GPD Host All right reserved.