Wednesday, May 06, 2015

MAMP PRO and Postfix

MAMP PRO only uses Postfix from Mac OS X to implement basic mail-sending capabilities. It was designed to help developers to check if their mail scripts are working correctly, to see if all the information that is supposed to be in a mail, is really there, to check the layout and so on. It was never intended to use Postfix as a full-fledged email server replacement. Please keep that in mind.

A minimal Postfix setup is simple. We use Googles Gmail service as an example to demonstrate the workings of Postfix.

In the Postfix section of MAMP PRO please set the domain of outgoing emails to "gmail.com". Leave the Smart Host checkbox unchecked.

Click the Button "Use this data". In Postfix' log file you will see something like

Dec 12 09:10:48 Tonne postfix/master[31865]: daemon started -- version 2.9.4, configuration /etc/postfix

The log file is located at /var/log/mail.log and can be viewed with Console.app.

In MAMP PRO, create a host (let's call it postman) and assign it a document root folder.

In a text editor create a PHP script, a basic mail-sending PHP script would look like

Please replace to.address@gmail.com and from.address@gmail.com with working Gmail addresses. Save the script to the document root folder of postman.

Make sure the servers of MAMP PRO are running and click on the right arrow located next to the field "Server name" in the General section of the Hosts view. Your web browser should open and show the message "Testing Postfix...".

In /var/log/mail.log new entries will appear, similar to

Dec 12 09:11:26 Tonne postfix/pickup[31994]: EF76490ECED: uid=502 from= 
Dec 12 09:11:26 Tonne postfix/cleanup[31995]: EF76490ECED: message-id=<20141212081126 .ef76490eced="" mailer.gmail.com=""> 
Dec 12 09:11:27 Tonne postfix/qmgr[31997]: EF76490ECED: from=, size=391, nrcpt=1 (queue active) 
Dec 12 09:11:28 Tonne postfix/smtp[31998]: EF76490ECED: to=, relay=gmail-smtp-in.l.google.com[74.125.136.27]:25, delay=2.2, delays=1.1/0.02/0.38/0.69, dsn=2.0.0, status=sent (250 2.0.0 OK 1418371832 k5si1095875wjf.30 - gsmtp) 
Dec 12 09:11:28 Tonne postfix/qmgr[31997]: EF76490ECED: removed

The most important information is status=sent. This means Postfix has handed the message over to Gmail which has accepted it. The last line indicates that Postfix has removed the message from its local queue, Postfix has done its work!

If, and where to, Gmail delivers the message is out of the hands of Postfix now. Please check your spam folder if the message does not show up in your inbox. Make sure you are looking in the correct spam folder, on Gmails webpage it's hidden behind "More" in the folder hierarchy on the left side.

If you need more sophisticated email capabilities you might want to use a Smart Host. In this case, please contact your email provider for the correct settings. Typically, free accounts do not have smart host capabilities.

Share/Save/Bookmark

Thursday, February 19, 2015

Editing your httpd.conf file in MAMP PRO

Your MAMP PRO Apache Server httpd.conf file is located in your ~/Library/Application Support/appsolute/MAMP PRO directory. ~/Library is a hidden folder, you will need to unhide it in the Mac Finder or use some other utility to see hidden folders. This file cannot be edited directly. MAMP PRO will overwrite this file every time it starts up the Apache Server. Changes you make to this file will be lost.

The httpd.conf Template File

Modifications to the Apache Server directives need to be done through the MAMP PRO interface, or the httpd.conf template file. You can open the httpd.conf Template file through the MAMP PRO menu.



The httpd.conf Template file text and all other template files are color formatted. MAMP directives are in red, text that will be directly written into the real httpd.conf file are black, while comments are brown. The following is an example of a directive that is commented out by default.

#CustomLog "/Applications/MAMP/logs/apache_access.log" combined

When you uncomment this directive an apache_access.log file will be created in your /Applications/MAMP/logs directory. You can now see how many “hits” each your hosts are receiving.



You could also create an apache_access.log file for each host. Make use a MAMP PRO directive to achieve this. 



The following directive, added to the httpd.conf Template file, will create a unique apache_access file in your /Applications/MAMP/logs directory. This directive is placed inside of the 

MAMP_VirtualHost_iteration_begin_MAMP loop. Add the following line.

CustomLog "/Applications/MAMP/logs/MAMP_VirtualHost_ServerName_MAMP_apache_access.log" combined


Now that this line has been added to your httpd.conf Template file, save your changes and restart your servers. In your Applications/MAMP/logs directory you will now have an hostName_apache_access.log file for each host.

Verifying Your Changes [ MAMP PRO Interface > httpd.conf template > httpd.conf ]

Working with MAMP directives can sometimes be tricky. If your Apache Server does not start, then check the real httpd.conf file to verify your changes are syntactically correct. All changes made in the interface, as well as the httpd.conf file will eventually flow to your real httpd.conf file. The real httpd.conf file is located in ~/Library/Application Support/appsolute/MAMP PRO. Check the timestamp to verify this file was just created.

SSL Sites

To make changes to your ssl sites use the httpd-ssl.conf template file. Changes in this file will be reflected in the httpd-ssl file located in ~/Library/Application Support/appsolute/MAMP PRO.



Share/Save/Bookmark

Wednesday, February 04, 2015

The .htaccess File and MAMP PRO

The .htaccess file is an Apache Server configuration file. Many content management systems use them. They are used for custom configuration of Apache Server for a host. Changes to the access of your .htaccess file can be made in the General section of the Hosts tab.

Enabling the .htaccess File

By default your MAMP PRO Apache Server is configured with the .htaccess file enabled. The  [ AllowOveride All ] directive allows any directive with .htaccess context to override the Apache Server configuration.


Set the AllowOverride directive to [None] if you wish to disable your .htaccess file.


More information concerning the AllowOverride Directive can be found at the Apache Server website.



The .htaccess File Is Hidden

You will not see a .htaccess file in the Mac Finder because it is a hidden file. An easy way to see if a .htaccess file exists in a directory, or open the file itself, is by using the text editor TextWrangler. From TextWrangler go to File -> Open.  Click Show Hidden Items. You will now see if a .htaccess file is in the directory, and open it if you wish.




Wordpress and .htaccess

Many content management systems will dynamically create .htaccess files to make customisations to Apache Server. One example are permalink settings in WordPress.



Wordpress will create a .htaccess file when you set your permalink settings to anything other than Default. You will not be able to see your blog pages if you have your AllowOverride set to None and your permalink settings set to anything other than Default.

The following is the content of the .htaccess file that is created when you set the permalink to Day and name.



Create Your Own .htaccess File

You can also create your own .htaccess and make your own Apache Server customisations. Use a text editor such as TextWrangler to create a .htaccess file. You may get a warning that you are about to create a hidden file when you do. The following .htaccess file directive will make Apache Server first look for MyCoolIndex.php instead of the customary index.html and index.php.

Add the following line to your newly created .htaccess file:

DirectoryIndex MyCoolIndex.php index.html index.php

Share/Save/Bookmark

Wednesday, January 28, 2015

How to: Creating multiple Apache log files on a per host basis

By default MAMP PRO logs your Apache errors in /Applications/MAMP/logs/apache_error.log. Errors originating from all hosts are entered into this single log file. It may be more convenient to have one log file for each individual host.

Open up your httpd.conf template file (Go to > File > Edit Template > Apache > httpd.conf) and scroll down to the “MAMP_VirtualHost_iteration_begin_MAMP” directive. Inside the httpd.conf template file add the following Errorlog directive (see line 10 in this code snippet).



This will create multiple log files in your /Applications/MAMP/logs directory. They will be named MyHostName1.log, MyHostName2.log, ….

Double check your work in your real httpd.conf file which is created every time you start your Apache server in ~/Library/Application Support/appsolute/MAMP PRO . You should see the following changes under each individual host. The following is the localhost:




UPDATE:
There´s a second method to generate multiple Apache log files:
You can create individual Apache error log files through the MAMP PRO interface. In the Hosts tab, under the Extended section you can add the following under the Additional parameters for "VirtualHost": section.

Advantages/Disadvantages

Method 1 - You only have to make one change to your httpd.conf template file and each subsequent host you create will have an Apache error log file created for it without any additional work. The disadvantage is you have less control over the name and location of your custom Apache log file.

Method 2 - You have more control over the name and location of your custom Apache log file. The disadvantage is that you have to enter the custom Apache log file name for each additional host you create. Error messages will appear in the default apache_error.log file If you forget adding a custom Apache error log file name for a particular host.

Share/Save/Bookmark

Tuesday, January 27, 2015

MAMP & MAMP PRO for Windows Preview Release

We´ve released a free preview version of MAMP & MAMP PRO for Windows. It runs under Windows 8.1, Windows 8.0 and Windows 7. A minimum of 2GB free HD space is required.

This version contains all features of the Mac OS X version. You can test the MAMP & MAMP PRO for Windows Preview until 15th of February 2015. After this we´ll provide an advanced beta version of MAMP & MAMP PRO for Windows. The preview can be downloaded here.

Share/Save/Bookmark

Monday, December 15, 2014

MAMP PRO: Postfix - The Ultimate Guide

MAMP PRO only uses Postfix from Mac OS X to implement basic mail-sending capabilities. It was designed to help developers to check if their mail scripts are working correctly, to see if all the information that is supposed to be in a mail, is really there, to check the layout and so on. It was never intended to use Postfix as a full-fledged email server replacement. Please keep that in mind.

A minimal Postfix setup is simple. We use Googles Gmail service as an example to demonstrate the workings of Postfix.

In the Postfix section of MAMP PRO please set the domain of outgoing emails to "gmail.com". Leave the Smart Host checkbox unchecked.

Click the Button "Use this data". In Postfix' log file you will see something like

Dec 12 09:10:48 Tonne postfix/master[31865]: daemon started -- version 2.9.4, configuration /etc/postfix

The log file is located at /var/log/mail.log and can be viewed with Console.app.

In MAMP PRO, create a host (let's say you call it 'postman') and assign it a document root folder.

In a text editor create a PHP script, a basic mail-sending PHP script would look like:



Please replace 'to.address@gmail.com' and 'from.address@gmail.com' with working Gmail addresses. Save the script to the document root folder of 'postman'.

Make sure the servers of MAMP PRO are running and click on the right arrow located next to the field "Server name" in the General section of the Hosts view. Your web browser should open and show the message "Testing Postfix...".

In /var/log/mail.log new entries will appear, similar to


The most important information is "status=sent". This means Postfix has handed the message over to Gmail which has accepted it. The last line indicates that Postfix has removed the message from its local queue, Postfix has done its work!

If, and where to, Gmail delivers the message is out of the hands of Postfix now. Please check your spam folder if the message does not show up in your inbox. Make sure you are looking in the correct spam folder, on Gmails webpage it's hidden behind "More" in the folder hierarchy on the left side.

If you need more sophisticated email capabilities you might want to use a Smart Host. In this case, please contact your email provider for the correct settings. Typically, free accounts do not have smart host capabilities.


Share/Save/Bookmark

Tuesday, October 21, 2014

Screencasts on MAMP.TV

A few weeks ago we started our youtube channel MAMP.TV You will find how to´s, walkthroughs and trouble shooting tips about MAMP & MAMP PRO. 



We already published a set of 12 videos. Most viewed is out MAMP PRO Introduction followed by the installing Wordpress on MAMP PRO screencast.
We´ll keep this up and we´ll publish more tutorial and videos about MAMP in the future.


Share/Save/Bookmark