Send your emails by SMTP

Using an SMTP server

Using SMTP improves the reliability of your site's emails considerably compared to the PHP mail method used by default. This reliability is important in order to properly receive all emails sent by your site's forms but also all online orders from your store. Before that, make sure that your site works well online and if you have not yet published it to your host then refer to our advice in order to publish your site  for the first time using PHP mail.

SMTP configuration in TOWeb

In order to be able to send SMTP email from your site you need to have all the necessary information to connect your email server, that is to say:

  • your email address
  • your password
  • the SMTP server name to use (*)
  • the SMTP port to use (*)

(*) = if TOWeb recognizes your email this information will be automatically pre-filled for you, otherwise you will have to contact your email provider to find out.

Once you have this information, you can add your email account in TOWeb and use SMTP email sending on your site by following these steps:

  1. click on the  button located in step 4/5 of the host configuration wizard (accessible by CTRL + F8)
  2. enter your email address and password (as well as the server name and port if these fields are not automatically filled in by TOWeb). Unless your email provider has advised you of a specific encryption mode, we advise you not to worry about this option and to leave the choice on "auto"
  3. then click on OK
  4. your message account thus created can then be selected in TOWeb to be used on your site
  5. click on the test button to ensure that you receive the test email. If this does not work, then make sure that you have not made any mistakes in the information you have entered and then update it before doing a new test. Also check that no security system on your computer is blocking TOWeb
  6. then go to the last step of the wizard to validate your changes.

Note: if the email account you want to use to send your messages is a Gmail or Yahoo address, then you will need to enable the "SMTP OAuth2" option and perform additional security configuration steps by referring to the SMTP with Google and SMTP with Yahoo procedures.


Using Google's SMTP server

Google allows you to use the Gmail SMTP server to send emails from your site for free (up to a maximum of 500 emails per day) and requires a minimum of PHP version 8 on your hosting. The procedure to follow consists of 2 major steps which are as follows:

  1. create a Google application that will allow you to connect to the Gmail SMTP server via the Google API (instead of just entering the SMTP details). This step requires following many mandatory security configuration steps (count between 30 minutes and 1 hour if it is your first time) but that you will only have to do once in order to obtain the Gmail OAuth2 SMTP credentials of your site
  2. use your GMail OAuth2 credentials in TOWeb.

Note: if you have just created your site and have never published it before, we advise you to start by publishing your site for the first time by sending it via the PHP mail function of your host.

1) Create your Google App

To get started, open your web browser and sign in to your Google account from the Google Developers Console. If this is your first time signing in to the Developer Console, Google will ask you to create your first project. If you already have projects, you can create a new one by clicking the drop-down menu in the upper-left corner.
Enable APIs and Services of Google

Once in your project, click the button to enable the APIs and services (see screenshot above). In the next screen, search for “Gmail” and choose the Gmail API result to enable it. Once this is done you should be in a dedicated interface for the Gmail API from which you can do the following:

1.1) Click the button to create your credentials
1.2) Then fill out the form using the following information:

  • Which API are you using?
    Gmail API
  • Where will you call the API from?
    Web browser (JavaScript)
  • What data will you have access to?
    User data

1.3) Then click the “What credentials do I need” button. Google will ask you to create a consent screen. This is the same type of authorization screen you see when you use Google to sign up or log in to a site. You need to do this to meet Google’s requirements, but you don’t need to worry about what information you enter because you (and only you) have your information for your own site.

1.4) Next, use the button to Set Up Consent Screen. This should open a new tab where you can set up an OAuth consent screen (keep the original browser tab because you’ll need to come back to it). Under "User Type", select "External".

1.5) Next, click "Create". On the next screen, enter your site’s basic details. Again, you don’t need to worry about what you put here because you’re the only person who sees this information. Once you’ve added the information, click "Save" at the bottom of the page.

1.6) Go back to your project credentials page and enter the following information:

  • Name
    your website name
  • Authorized redirect URIs
    the following web address, replacing "xxxx.xx" with your website domain name:https://xxxx.xx/_iserv/sendmail/PHPMailer/get_oauth_token.php

1.7) Then click the "Refresh" button (located at the end of the page) to update your credentials and then Create OAuth Client ID to complete the process. Once done, you should see a section for OAuth 2.0 Client IDs in your project's Credentials tab.

Google's OAuth2 identifiers
1.8) Finally, click on the name of the site that you have just created (here in our example "Website 1") in order to view and keep the following 2 identifiers (because you will have to copy/paste them into TOWeb in the next step):
  • your client ID
  • and your client Secret
SMTP OAUTH2 GMAIL configuration in TOWeb

2) Use your OAuth2 IDs in TOWeb

Once you have the OAuth2 credentials of your site previously obtained from your Google account, you can add and use your Gmail email account by following these steps:
  1. click on the  button located in step 4/5 of the host configuration wizard (accessible by CTRL + F8) to add your email account
  2. then enter your Gmail email address. TOWeb will then automatically fill in all the other fields (server, port, encryption) that you normally do not have to modify
  3. activate the SMTP OAuth2 option (entering your password may not be necessary when using SMTP OAuth2)
  4. copy to the clipboard each client credential (previously obtained in step 1.8) and use the paste buttons [1] to fill both TOWeb form fields
  5. check that the redirection URI address that you previously indicated to Google is the same as the one displayed by TOWeb. If necessary, use the button [2] to copy and paste it into your Google account to correctly update this address (previous step 1.6)
  6. then click on the button [3] which will redirect you to the page of your site containing a form to fill out in order to obtain the latest security identifier "Refresh token" allowing the use of your Gmail account from your website. Once this form is filled out and validated, you will then obtain this "Refresh token". Do not close your web browser window because this "Refresh token" is very important and must be kept very carefully. In addition to copying/pasting it in field [3], we advise you to also keep it elsewhere (such as in your usual password management tool) in order to be able to reuse it in the event of a problem (such as losing your site data)
  7. then click OK to finish adding your email account to TOWeb
Your Gmail account thus created can then be selected in TOWeb to be used in your site after having previously clicked on the test button to ensure that you receive the test email. If this does not work, then make sure that you have not made any mistakes (in your copy/paste in particular) by repeating all the steps and also check that no security system on your computer is blocking TOWeb.

Using Yahoo's SMTP server

Yahoo Mail allows you to use their SMTP server to send emails from your site for free with a sending limit of 500 emails per day (exactly like Gmail). However, Yahoo Mail is not always compatible with sites and hosting, and you may encounter problems when setting it up. This is mainly due to the fact that Yahoo Mail has quite strict firewall rules to combat spam sending. For this reason, we recommend that you preferably use another free SMTP server, such as Gmail's SMTP server, which is often easier to operate but also more durable and less problematic over time, especially if you are one day forced to change hosts.

If you want to use Yahoo Mail's SMTP server, the procedure will be exactly the same as Google's, that is to say, create an App from your Yahoo Mail account by following Yahoo's instructions (in English) in order to obtain your two OAuth2 identifiers which will allow you to add your email account in TOWeb and obtain your "Refresh token" security identifier which is necessary for sending emails from your site via SMTP. And just like for Google, you will need your site to be published on a web server using at least version 8 of PHP.


Using PHP mail

If you have never configured or published your site to your host server, we advise you to make at least one publication by first using the PHP mail() function of your host. This will not only ensure you that everything works well on your site without PHP incompatibility or errors detected by TOWeb at the level of your server, but also that you have not made any mistakes such as for instance a bad subdirectory name in step 3/5 of the host configuration wizard CTRL + F8 or OAuth2 errors.

For the sending and receiving test, you must use the email address of your site (and not a free one like @gmail or @yahoo) as it may be refused by your host and no email will ever be sent. In other words, if your site has for example the domain name "mysite.com", you will have to use your email address "@mysite.com" (and in the same way if your site is published on a free hosting or personal web space such as for example Free then you will have to use your email address @free.fr).

Once your site is perfectly functional on the internet, you can then add an SMTP account in order to increase the reliability of sending your emails or return at any time to using PHP mail if any problem.


Page 13 of 38
Link copied to clipboard