In this article we will talk about quick and easy setup of the SMTP server in your
Jelastic environment. SMTP stands for Simple Mail Transfer Protocol. This is the standard for sending email over the Internet. SMTP is used when email is delivered from an email client to a server or from one email server to another. Communication between the sender and the recipient takes place in text form using a reliable channel (usually TCP). SMTP is a reliable and simple protocol.

In this article we will explain how to use Jelastic PHP for SMTP. Two options will be considered: using
PHPMailer or your own form to send email.
Creating the environment
1. If you do not have a Jelastic account in InfoboxCloud,
create it .
2. Click
“Create Environment” and select the type of
PHP environment.
3. Select the
Apache server and set the boundaries for the vertical scaling. Add a
public IP address to the Apache node. Enter the name of the environment, for example
phpmailer and click
Create .
')

Now you can configure
SMTP . First, consider the
PHPMailer settings.
PHPMailer to send email
PHPMailer is a classic full-featured class for sending mail in PHP, compatible with PHP v.5 and higher. Let's see how this is done in
Jelastic on the InfoboxCloud platform .
1. Download the
PHPMailer script. (the modified version of the link includes all settings and is intended only for
SMTP ).
2. Open the “Distribution Manager” and upload the script to Jelastic.

3. When the download is complete, deploy
PHPmailer to the environment you created earlier.

Next, click
the Settings button in your application server and go to
webroot / {context_name} /config.php
In this configuration file, you can configure the mail sending data:
- via localhost
- through a specific email account
Sending from Localhost
You can send emails directly from your application without specifying a real email account. In this case, you do not have any restrictions on the frequency and number of emails sent, but mail can easily get into spam.
To use this configuration, you need to set the following parameters:
- host : value "localhost"
- auth : value "false"
- username : sender name
- addreply : email address that will be used to reply to emails. This is a required parameter.
- replyto : set the same value as in addreply.

Save your changes. After that you can click on the "Open in browser" button.

You will see the form to send email.

Enter the information in the form fields and click
"Submit" . In a few minutes the letter will be delivered to the specified email address.

If you haven’t received a letter in a few minutes, check Spam.
Sending from a real email account
You can use this method if you have a registered account in an existing email. In this case, the letter most likely will not fall into spam, but you may encounter restrictions on the number of letters sent per unit of time. Below is an example of setting up with
gmail :
- host : ssl: //smtp.gmail.com
- port : 465 (port of your email provider)
- auth : true value
- username : your login from the mail service
- password : your password from the mail service
- addreply : your email address
- replyto : your email address
Save the changes. Then click on the
“Open in browser” button in your environment.

Enter the test data and click
"Submit" . An email will be sent.

This is all you need to successfully send emails with PHPMailer. Using this guide, you can try to configure other email – systems.
Now let's see how to create your own form to send letters.
Using a free form to send email
You can make your own form to send email.
1. Click “Configuration” on the web environment.

2. Go to
webroot / ROOT (or to another context folder) and create a new file: for example,
mailtest.php .

3. Write the form code in mailtest.php, for example:
<form method = POST ation = #>
From <input type = text name = from> <br />
To <input type = text name = to> <br />
Subject <input type = text name = subj> <br />
Type your message <input type = text name = text> <br />
<input type = submit name = sub value = Send>
</ form>
<? php
if ($ _POST ['sub']) {
system ("echo {$ _POST ['text']} | mail -s {$ _POST ['subj']} -r {$ _POST ['from']} {$ _POST ['to']}");}
?>
Save the change. Now open our environment in the browser and add the file name to the path.

You can use both localhost (just type localhost in the From field) and the real email address to send.
As a result, we get an email.

That's how simple it is. You can send emails directly from your application deployed in Jelastic.
Successful use of
Jelastic in the
InfoboxCloud cloud.