Send emails through SMTP authentification


As of 31/03/2015, PHP Mail() function has been disabled on shared Linux servers for security reasons. These measures were taken primarily to avoid problems caused by IP blacklisting for spam. Blacklisting of the IP will lead to the impossibility of sending emails to all clients on the server.

Below are the necessary settings, depending on the platform used, to configure sending emails via SMTP.



1. No platform or CMS installed:

You can send messages through SMTP by inserting the following PHP code:

  ini_set("include_path", '/home/username/php:' . ini_get("include_path") );
  require_once "Mail.php";
 
  $from = "name <email@domain.com>";
  $to = "name <email@domain.com>";
  $replyto = "name <email@domain.com>"
  $subject = "Subject\r\n\r\n";
  $body = 'Message';               
 
  $host = "server_hostname";
  $username = "email@domain.com";
  $password = "the_password_from_email_account";  
                        
 
  $headers = array ('From' => $from,
                'To' => $to,
                'Subject' => $subject,
                'Reply-To' => $replyto);
  $smtp = Mail::factory('smtp',
                array ('host' => $host,
               'auth' => true,
               'username' => $username,
               'password' => $password));
 
  $mail = $smtp->send($to, $headers, $body);
 
  if (PEAR::isError($mail)) {
                echo("<p>" . $mail->getMessage() . "</p>");
  } else {
                echo("<p>Mesaj trimis cu succes!</p>");
  }

 

username -> your cPanel username
domain.com -> your domain
server_hostname -> your server hostname where your website is hosted (ex. artemis.elvsoft.net, hera.elvsoft.net, etc.); you can find the server hostname by logging into your cPanel account, make sure you are using paper_lantern theme, go to Statistics like in the image below. After click on Server Information. Next to Server Name is specified the server name. The finall adress will be artemis.elvsoft.net




 cpanel statistics


cpanel server statistics


Search in cPanel -> PHP PEAR Packages and install the following modules:

Auth
Auth_HTTP
Auth_SASL     
Auth_SASL2
Mail
Mail2
Net_SMTP
Net_Socket     




2. WordPress:

You can install on of the following plugins:
https://wordpress.org/plugins/wp-mail-smtp/




3. Joomla:

For Joomla you will need to do the following:

a. Login to administration area
b. Go to Site >> Global configuration
c. In the Server tab use the following settings:

Mailer: choose SMTP.
SMTP Authentication: choose Yes.
SMTP Security: choose None.
SMTP Port: use port 26.
SMTP Username: email@domain.com (your email account)
SMTP Password: (the password from your email account)
SMTP Host: localhost

Usefull links:

http://www.serversmtp.com/en/smtp-joomla-settings


4.Typo3

Edit the file public_html/typo3conf/localconf.php and change the following:

$TYPO3_CONF_VĂRS['MAIL']['transport'] = 'smtp';
$TYPO3_CONF_VĂRS['MAIL']['transport_smtp_server'] = 'localhost';
$TYPO3_CONF_VĂRS['MAIL']['transport_smtp_username'] = 'email@domain.com';
$TYPO3_CONF_VĂRS['MAIL']['transport_smtp_password'] = 'password';

5.Magento

You can install the following plugin:

http://www.magentocommerce.com/magento-connect/smtp-pro-email-free-custom-smtp-email.html
 

6.Prestashop



For Prestashop you need to do the following: 

a. Login to the administration area. 
b. Go to Advanced Parameters >> E-mail >> Set my own SMTP parameters
c. In the Email tab, on the bottom use the following settings: 

Mail domain name: Domain name (It's not mandatory)
SMTP Server: mail.domain.tld 
SMTP Username: email@domain.tld 
SMTP Password: password
Encryption: None
Port: 25

Prestashop SMTP settings

Usefull links:
https://www.prestasoo.com/Blog/prestashop-smtp-settings-so-easy.html


7.Opencart


For Opencart version 3.0.2.0(exemplified below) you need to follow the next steps (the settings remain the same for versions 2.3.0.2 si 1.5.6.4): 

a. Login to the administration area. 
b. Go to Settings >> Store Name >> Actions >> Edit 

Opencart settings - 1

c. In the Email tab, on the top use the following settings:

Opencart settings - 2

Mail Engine: SMTP
Mail Parameters: mail address
SMTP Hostname: server name (Ex: iris.hosterion.net)
SMTP Username: mail address
SMTP Password:mail address password 
SMTP Port: 25 or 465(SSL)

 

For any further information, please contact us!


  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

Cleaning sites that are infected via FTP

Infection of a website  via FTP, involves the injection of site code into an <iframe>...

Email account configuration in Plesk

In this article we will describe the steps necessary to create a new email account, adding email...

How to configure an email client account

  Bellow you will find the steps that you need to make in order to create a new email account,...

Setup an email account in Thunderbird

In the following tutorial, you can find the steps that can help you setup an email account in...

Setup an email account in Outlook 2007

In the following tutorial, you can find the steps that can help you setup an email account in...