Easy Guide Steps for Email Settings in Virtualizor
Like any control panel and service, it’s crucial to be able to send emails to users. Notifying users about their account and service status is a vital function. This article will describe how to configure email settings in Virtualizor. We will also learn how to edit email templates.
How to Edit Email Settings in Virtualizor?
This tutorial will guide you through enabling and editing Virtualizor email settings. A critical aspect of email service is having well-defined email templates and sending emails based on those templates. We will cover how to edit these email templates. Please follow the steps below.
Step 1 – Where is Email Settings in Virtualizor?
First, log in to your Virtualizor panel by entering ServerIP:4085
in your browser. Enter your login credentials to access the Virtualizor main page. Navigate to "Configuration >> Email settings" to find the Email settings in Virtualizor, as shown below.

Step 2 – Edit Email Settings
As you can see in the image, the first field allows you to select the "Mailing Method" from a drop-down list. There are two options: "PHP Mail" and "SMTP".
Using SMTP is a beneficial option in Virtualizor. We will examine both options. You can learn more about Google’s SMTP service.
Step 2-1 – PHP Mail
This option is the default. All emails will be sent using the PHP mail()
function. If you want to Disable Email service, check the checkbox and click "Edit Settings" to apply the changes.
Step 2-2 – SMTP Settings
If you select SMTP
from the drop-down list, you will see fields similar to the image below in the Virtualizor Email Settings.
Enter the SMTP Server address and the SMTP Port number. You can use 465
or 587
as the port number. Provide the SMTP Username and SMTP Password in the next two fields. Then, select the Secure Connection type using the radio buttons. You can choose from None
, SSL
, and STARTTLS
.
Set the Connection Timeout field with a number representing seconds. This determines how long Virtualizor will wait to establish a connection with the SMTP server. You can Enable Debugging mode to save logs in the /var/virtualizor/log/email/email.log
file.
The Disable Email option is also available here to prevent sending emails. Finally, click "Edit Settings" to save the Email Settings Virtualizor configuration.
Step 3 – Email Templates
Navigate to "Configuration >> Email Templates" to view all available templates in Virtualizor. These templates are used to notify users about services and their status.
Click the edit icon at the end of each line to customize the content of each email. Green circles indicate that the template is enabled. You can disable or enable any template. Select the emails you want to modify, choose "Disable Templates" from the drop-down list, and click "GO" to apply the changes. Properly configuring email settings in Virtualizor is essential.
Conclusion
In this article, we learned how to configure email settings in the Virtualizor panel. We also explored how to edit email templates. You might be interested in reading our other articles about Virtualizor from this link. Configuring effective email settings in Virtualizor are important to ensure proper communication with users.
I’m honored to share my knowledge with anyone. Feel free to comment below if you have any questions. Properly configured email settings in Virtualizor improve user experience.
Alternative Solutions for Email Delivery in Virtualizor
While the above method details using PHP Mail or direct SMTP configuration within Virtualizor, there are other approaches to achieve reliable email delivery, especially when dealing with potentially high volumes or deliverability concerns. Here are two alternative solutions:
1. Using a Transactional Email Service (e.g., SendGrid, Mailgun, Amazon SES)
Explanation:
Transactional email services are designed specifically for sending automated, triggered emails like account notifications, password resets, and service updates. They offer several advantages over direct SMTP or PHP Mail, including:
- Improved Deliverability: These services have established relationships with ISPs and employ sophisticated techniques to minimize the risk of emails being marked as spam.
- Scalability: They can handle large volumes of emails without impacting server performance.
- Detailed Analytics: They provide insights into email delivery rates, opens, clicks, and bounces, allowing you to optimize your email campaigns.
- Dedicated Infrastructure: They manage the complexities of email infrastructure, freeing you from having to worry about server configuration, IP reputation, and other technical details.
Implementation:
Instead of configuring SMTP directly in Virtualizor, you would integrate with a transactional email service’s API. This typically involves the following steps:
- Sign up for an account with a transactional email service like SendGrid, Mailgun, or Amazon SES.
- Obtain API credentials (API key or username/password) from the service.
- Install the service’s client library for your preferred programming language (likely PHP, given Virtualizor’s environment) on the server running Virtualizor.
- Modify Virtualizor’s email sending logic to use the client library to send emails via the transactional email service’s API. This will likely involve creating a custom script or modifying existing Virtualizor files (consult Virtualizor documentation for the best approach).
Code Example (PHP with SendGrid):
<?php
require 'vendor/autoload.php'; // If you're using Composer
$apiKey = getenv('SENDGRID_API_KEY');
$email = new SendGridMailMail();
$email->setFrom("test@example.com", "Example User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("test@example.com", "Example User");
$email->addContent(
"text/plain", "and easy to do anywhere, even with PHP"
);
$email->addContent(
"text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
$sendgrid = new SendGrid($apiKey);
try {
$response = $sendgrid->send($email);
print $response->statusCode() . "n";
print_r($response->headers());
print $response->body() . "n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."n";
}
?>
Explanation of Code:
require 'vendor/autoload.php';
: This line includes the autoloader generated by Composer, which makes the SendGrid library available in your script. If you haven’t used Composer before, you’ll need to install it and use it to install the SendGrid PHP library:composer require sendgrid/sendgrid
.$apiKey = getenv('SENDGRID_API_KEY');
: This retrieves the SendGrid API key from an environment variable. Never hardcode your API key directly in your script. Storing it in an environment variable is much more secure.$email = new SendGridMailMail();
: This creates a newMail
object, which represents the email you’re going to send.$email->setFrom(...)
,$email->setSubject(...)
,$email->addTo(...)
: These lines set the sender, subject, and recipient of the email.$email->addContent(...)
: This adds the email content, both in plain text and HTML formats. Providing both formats is good practice for compatibility with different email clients.$sendgrid = new SendGrid($apiKey);
: This creates a new SendGrid object, passing in your API key.$response = $sendgrid->send($email);
: This sends the email and stores the response from the SendGrid API.- The
try...catch
block handles any exceptions that might occur during the email sending process.
Benefits: Improved deliverability, scalability, detailed analytics, simplified email infrastructure management.
Drawbacks: Cost (transactional email services typically charge based on the number of emails sent), requires code modification within Virtualizor.
2. Using an Email Relay Service (e.g., Postfix with a Smarthost)
Explanation:
An email relay service acts as an intermediary between your server (running Virtualizor) and the final email destination. Instead of sending emails directly, your server forwards them to the relay service, which then handles the delivery to the recipient’s mail server. This is often achieved by configuring Postfix (a common mail transfer agent) as a "smarthost."
Implementation:
- Install and configure Postfix: If not already installed, install Postfix on the server running Virtualizor.
- Configure Postfix as a Smarthost: Modify the Postfix configuration file (
/etc/postfix/main.cf
) to specify the relay service’s SMTP server as the smarthost. This typically involves setting therelayhost
parameter. You’ll also need to configure authentication if the relay service requires it. - Update Virtualizor’s SMTP settings: Configure Virtualizor to use
localhost
(127.0.0.1) as the SMTP server, effectively sending emails to Postfix on the same server.
Code Example (Postfix Configuration Snippet in /etc/postfix/main.cf
):
relayhost = [smtp.example.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_security_level = may
Explanation of Code:
relayhost = [smtp.example.com]:587
: Specifies the hostname (or IP address) and port of the relay service’s SMTP server. Replacesmtp.example.com
with the actual hostname and587
with the appropriate port. The square brackets around the hostname force Postfix to perform a DNS lookup only once at startup, which can improve performance.smtp_sasl_auth_enable = yes
: Enables SMTP authentication.smtp_sasl_security_options = noanonymous
: Prevents anonymous authentication attempts.smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
: Specifies the location of the file containing the username and password for the relay service. This file should be created and secured properly.smtp_tls_security_level = may
: Attempts to use TLS encryption, but falls back to unencrypted communication if TLS is not available. Useencrypt
for mandatory TLS encryption.
You would then create the /etc/postfix/sasl_passwd
file with the following format:
[smtp.example.com]:587 username:password
After creating this file, you would secure it and generate the hash file:
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
Finally, restart Postfix:
systemctl restart postfix
Benefits: Centralized email management, improved deliverability (depending on the relay service), can be more cost-effective than transactional email services for lower volumes.
Drawbacks: Requires server administration knowledge, potential for increased complexity, reliance on the relay service’s infrastructure.
Choosing the right solution depends on your specific needs, budget, and technical expertise. For simple setups with low email volumes, PHP Mail or direct SMTP might be sufficient. However, for more demanding environments, a transactional email service or an email relay service can provide significant benefits in terms of deliverability, scalability, and manageability.