Step-by-Step: Using SMTP for sending mails

Looking around the forum, I see that many users are having problems setting up and sending emails via SMTP. Isolated tips sometimes do NOT lead to success. Here I provide a structured step-by-step guide.

Step 1: Configure SMTP

1.1 Login as administrator

1.2 Enter Admin-Area

1.3 Open Utilities menu and go to Admin Settings

1.4 Scroll down to email settings and enter the credentials your provider has given to you


  • Check SMTP option.
  • Don't play around right now.
    Just use the settings your provider has given to you for now.

1.5 Save changes

Step 2: Test SMTP in Admin Area

2.1 Open Members menu and go to View Members

2.2 Find your "admin" account and the button for sending emails at the end of the row

2.3 Enter a test-subject and test-body.

I strongly recommend putting a serial number there. This will help you in case e-mails do arrive for example hours later.

2.4 Check "Display debugging info"

This may help you later on finding and fixing the error.

2.5 Send test-message

and confirm the dialog

2.6 Be patient

2.7 Be patient

Especially if there is something wrong, it may take longer than expected.

2.8 Success or Failure

Luckily you turned on debugging and were patient. The result is displayed

2.8.2 Sending message has failed

Go back to step 1.4 and change your settings.

Tipp Don't just guess on any servernames or port numbers. Most of the time the information provided by your provider is correct. If necessary, try all possible combinations or encryption-option + available portnumbers in a structured order.

Intentionally my first attempts failed. I had to go back to step 1.4 and change encryption setting.

2.8.1 Success

Quickly check if the test email has arrived in your mailbox

Continue with step 3, if the sending has worked.

Do not cross this line, if the tests have not worked up to here.

Step 3: Test with PHP code

Before we write the mail-function we actually want, we will first run a test.

3.1 PHP code in header-extras

Follow the next 10 steps:

(1) Start your code editor and...

(2) open the file hooks/header-extras.php.

(3) Copy the following source code from here into your file:


$mail = [
    "to" => "your-mail-address@your-mailserver.tld",
    "name" => "Your name",
    "message" => "Test-message (1)",
    "subject" => "Test-subject (1)",
    "debug" => 4


(4) Change the recipient email-address ("to") and (5) the recipient-name ("name") and...

(6) save the file.

(7) Switch to the browser and...

(8) reload any page of that web application.

You will see debug output directly in your page:

If this works fine, then...

(9) cut the code from header-extras.php and...

(10) save header-extras.php.

Step 4: Integrate with your PHP code

Insert the source code where you actually want to send your mails, for example in an after_update hook. Then test it, modify, test and repeat.

Tip Take one small step at a time, then test, then take the next step.


  • The "to" parameter must not contain more than one recipient.
  • There is no option for multiple recipients
  • Don't try to put a comma-separated or similar.
  • There is no "cc" nor "bcc" option.
  • Be careful with single quotes and double quotes when concatenating strings in PHP.
  • Even if the sending worked, email providers may consider your email as SPAM. This can have many reasons.
  • Make sure that the sender email address matches the domain name.


  • When concatenating strings start simple and test every step. If successfull, change the string and test again.
  • For multiple recipients create an array of strings and use foreach for sending.
  • Consider sending to an shared inbox which can be read by multiple users.
  • Consider using a modern code-editor with syntax highlighting. Such an editor will automatically show syntax errors and give hints how to solve them.
  • If step 2 was not successful, you do not need to continue with steps 3 or 4. It cannot work if the foundation is not there.
  • If sending worked, but still no mail arrives, check your SPAM folder.
  • Check the SMTP settings character by character to exclude spelling mistakes.

I hope this guide was helpful. Feel free to give me feedback by email.

Newsletter 2020/12
Highlight (Showcase/Idea): Tile View

Important Notice
The features shown in this "highlights" blog category are a showcase of things which can be done using AppGini, AppGini Helper Library, PHP, SQL, Javascript, JQuery, CSS and HTML. This definately does not mean that everything you can see here is part of our product. It took hours, sometimes days of research, trial-and-error, coding and testing. So, these showcases are not part of a 49$ library, they are not single-line copy&paste codes and they are not for sale. Just a demonstration of what can be done and what we did and do in paid projects for our customers.

In most data-centric scenarios the tabular view is very suitable. There are use cases where I would like to have a tiled view. Even better would be if the user could choose. For some time now I have been programming something like this as an extension to AppGini. This is the current state I would like to show you. Please give me feedback what you think and if you are interested in such an extension.

Card contents

In this tile view i don't want to see all columns, but only certain data. I also want to modify the display, for example bold text or insert pictures. For this I have programmed a "templates" funtionality. This is actually "only" texts templates with placeholders. Since the templates can contain HTML, I am very flexible in the presentation.

// Please note:
// this functionality is NOT part of AppGini Helper Javascript Library 
// nor Inline Detail-View plugin
// ...
var card = new AppGiniHelper.TV.Tiles.CardTemplate();
card.setPage(`<img src="%image%" class="img-responsive img-circle" /><b>%last_name%</b> %first_name% %middle_names%`);
// ...
new AppGiniHelper.TV.Tiles.Handler().setCardTemplate(card).init();

Different Card Templates

At the moment I have programmed three different tile representations.


Bootstrap panels with (optional) header and footer:


Simple tiles:


Tiles with front-page and back-page, both customizable. If the video does not start automatically, please press play button:

Switching View

Additional buttons, automatically created, for switching between table view and tile view:


The contents and formatting can be customized using a template text with placeholders. Additionally, all elements can be styled using CSS.


As always I hope you like the stuff I do and publish here. I would be pleased if you could give me feedback on this idea. What are you missing, what would you like to have? Would you be interested in such an extension? Please send me an email to Thank you for taking the time!