We use cookies

This site uses cookies from cmlabs to deliver and enhance the quality of its services and to analyze traffic..

Master SEO vocabulary with all essential terms and meanings here.

SMTP: Definition, Functions & Tips on How to Activate It

Last updated: Oct 13, 2023

SMTP: Definition, Functions & Tips on How to Activate It
Cover Image: Illustration of SMTP (Simple Mail Transfer Protocol)

What is SMTP?

SMTP, which stands for Simple Mail Transfer Protocol, serves as a crucial cornerstone within the global framework of email communication

At its core, an SMTP server possesses the vital role of dispatching emails seamlessly across various computer networks.

But how does this happen? If you look from the perspective of the SMTP function, this protocol collaborates with the Message Transfer Agent (MTA) to send emails.

Within this interplay, the MTA is responsible for controlling the Simple Mail Transfer Protocol during the sending process.

Beyond its active engagement in facilitating email transmission, this protocol also serves as a security measure for filtering incoming emails.

In order to better understand the concepts of the Simple Mail Transfer Protocol, let's delve into the explanation regarding its functions, working mechanism, and activation below.

SMTP Functions

As mentioned earlier, the function is mainly to ensure secure, reliable, and efficient email communication across computer networks.

However, apart from that, this protocol also serves several other functions in the email-sending process. Here are some of the SMTP functions you need to know:

  1. Identification: Through this protocol, the sending server can identify itself and provide necessary information, including email addresses. This helps the receiving server recognize the legitimate source of the email.
  2. Delivery and Relay: The sending server forwards the email message to the receiving server or a relay responsible for the final delivery. This process involves the protocol to manage the message delivery to the intended address.
  3. Delivery Error Messages: If issues arise during delivery (e.g. invalid email address or an inactive receiving server), the sending server will return an error message to the sender. This informs the sender that the email wasn't successfully delivered due to an error.
  4. Queue Control: This protocol also manages the email delivery queue. If the receiving server is inactive or busy, the sending server holds the email message in a queue.
  5. Protection from Spam: Some Simple Mail Transfer Protocols servers incorporate mechanisms to identify and control email spam. In this case, the server checks IP addresses, verifies DNS records, and employs other methods to ensure that the email sender is a legitimate entity.
  6. Communication Protocol: It serves as a standard protocol for communication between sending and receiving servers, which enables various types of email servers to interact and exchange messages without compatibility issues.

How SMTP Works

As a protocol that involves several important stages in the email-sending process, the main steps about how it works include:

1. Email Composition

The process begins with the sender composing an email message. This message includes the recipient's email address, subject, content, attachments, and other information.

Once the message is composed, the sender sends it to the email server using the MUA (Mail User Agent), a program used to send and receive emails.

2. Email Submission

After composing the email, you can submit it to the Gmail SMTP server over TCP port 25.

3. Email Delivery

The next step involves the server initiating the email delivery process to the recipient. Within the practice, the sending server contacts the recipient using the recipient server's IP address or domain name.

4. Receipt and Email Processing

Once the email is received, the server forwards it to the MDA (Mail Delivery Agent). In this process, the email is stored and awaits the user to retrieve it.

5. Access and Email Retrieval

The final step involves accessing and retrieving the email. In this step, the email stored in the MDA can be retrieved using the MUA.

However, recipients can also retrieve messages through the POP3 or IMAP protocols, allowing access to messages from various devices.

How to Set Up SMTP Server

Setting up Simple Mail Transfer Protocol on various platforms fundamentally follows similar principles. Here's a general guide for configuring it on several different platforms:

1. WordPress

First, you can send emails from your website using a chosen server. Accordingly, follow these steps to configure this protocol in WordPress:

  1. Log in to your WordPress admin dashboard.
  2. Install and activate a plugin like "WP Mail SMTP".
  3. Go to the "Settings" section and select "General."
  4. Scroll down to the "From Name" and "From Email" fields and ensure the email address is valid.
  5. Access the available plugin settings and input your server details. Typically, you will need information such as the server name of the mail protocol, port, security type, email account, and password.

2. Native PHP Scripts

If you're using native PHP scripts without a specific framework, you can send emails using external libraries like PHPMailer.

Here is a basic outline for a native PHP script:

<?php 

include "classes/class.phpmailer.php"; 

$mail = new PHPMailer; 

$mail->IsSMTP(); 

$mail->SMTPSecure = 'ssl'; 

$mail->Host = "localhost"; //Replace with your email provider's hostname

$mail->SMTPDebug = 2; 

$mail->Port = 465; 

$mail->SMTPAuth = true;

$mail->Timeout = 60; // Sending timeout (in seconds) 

$mail->SMTPKeepAlive = true;

$mail->Username = "admin@yourdomain"; //your email user 

$mail->Password = "XXXXX"; //Youremailpassword

$mail->SetFrom("admin@yourdomain","Sender namel"); //Set sender email

$mail->Subject = "Email Notification from Website"; //Email subject

$mail->AddAddress("admin@yourdomain","Recipient Name"); //Recipient email

$mail->MsgHTML("Email Sent from Website"); 

if($mail->Send()) {

echo "Message has been sent"; }else { echo "Failed to send the message"; }

?>

 

Note: Please replace "localhost", "admin@yourdomain", "XXXXX", and other placeholders with your actual email server details.

Here's an example setup using PHPMailer:

  1. Download and place the PHPMailer library in your project.
  2. Create your PHP script and import the PHPMailer library.
  3. Configure the principal settings such as host, port, email account, and password.

3. CodeIgniter

CodeIgniter is a popular PHP framework. Configuring Simple Mail Transfer Protocol in this framework involves modifying configuration files. Here's an overview of the CodeIgniter script:

<?php 

defined('BASEPATH') OR exit('No direct script access allowed'); 
 

use PHPMailer\PHPMailer\PHPMailer; 

use PHPMailer\PHPMailer\Exception; 
 

class Welcome extends CI_Controller { 

  public function __construct() { 

    parent::__construct(); 

    require APPPATH.'libraries/phpmailer/src/Exception.php'; 

    require APPPATH.'libraries/phpmailer/src/PHPMailer.php'; 

    require APPPATH.'libraries/phpmailer/src/SMTP.php'; 

    } 

      function index() { 

        // PHPMailer object 

        $response = false; 

        $mail = new PHPMailer(); 
 

        // SMTP configuration $mail->isSMTP(); 

       $mail->Host     = 'hostdomain.com'; //adjust according to the hosting/server domain used

        $mail->SMTPAuth = true; 

        $mail->Username = '[email protected]'; // user email 

        $mail->Password = 'xxxxxxxxxx'; // email password

        $mail->SMTPSecure = 'ssl'; 

        $mail->Port = 465; 

        $mail->Timeout = 60; // sending timeout (dalam detik) 

        $mail->SMTPKeepAlive = true; 

        $mail->setFrom('[email protected]', ''); // user email

        $mail->addReplyTo('[email protected]', ''); //user email 

        // Add a recipient 

        $mail->addAddress('[email protected]'); //recipient email 

        // Email subject 

        $mail->Subject = 'SMTP Codeigniter'; // email subject

        // Set email format to HTML 

       $mail->isHTML(true);

        // Email body content 

        $mailContent = "<h1>SMTP Codeigniterr</h1> 

          <p>Laporan email SMTP Codeigniter.</p>"; // email content

        $mail->Body = $mailContent; 

        // Send email 

        if(!$mail->send()){ 

          echo 'Message could not be sent.'; 

          echo 'Mailer Error: ' . $mail->ErrorInfo; 

        }else{ 

          echo 'Message has been sent'; 

        }

      }

    }

As to make these changes, follow these steps:

  1. Open the file application/config/email.php.
  2. Modify the settings according to the host information you are using.
cmlabs

cmlabs

WDYT, you like my article?

Latest Update
Last updated: Nov 21, 2024
Last updated: Nov 08, 2024
Last updated: Nov 06, 2024

Streamline your analysis with the SEO Tools installed directly in your browser. It's time to become a true SEO expert.

Free on all Chromium-based web browsers

Install it on your browser now? Explore Now cmlabs chrome extension pattern cmlabs chrome extension pattern

Need help?

Tell us your SEO needs, our marketing team will help you find the best solution

Here is the officially recognized list of our team members. Please caution against scam activities and irresponsible individuals who falsely claim affiliation with PT CMLABS INDONESIA DIGITAL (cmlabs). Read more
Marketing Teams

Agita

Marketing

Ask Me
Marketing Teams

Destri

Marketing

Ask Me
Marketing Teams

Thalia

Marketing

Ask Me
Marketing Teams

Irsa

Marketing

Ask Me
Marketing Teams

Yuliana

Business & Partnership

Ask Me
Marketing Teams

Rochman

Product & Dev

Ask Me
Marketing Teams

Said

Career & Internship

Ask Me

Interested in joining cmlabs? Boost your chances of becoming an SEO Specialist with our new program, cmlabs Academy. it's free!

Check

New! cmlabs Added 2 Tools for Chrome Extensions! What Are They?

Check

There is no current notification..