Difference between revisions of "Amahi Mail System"

From Amahi Wiki
Jump to: navigation, search
 
(495 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<b>DISCLAIMER:</b> Although this has been tested, use at your own risk. I cannot guarantee that it will work for your system or not cause any serious problems.
+
{{MessageBox|backgroundcolor = #FBB|
 +
image =Warning.png|
 +
heading =WARNING|
 +
message = This should only be attempted by advanced users.<br>It is still under development.}}
 +
<b>DISCLAIMER:</b> This is for Amahi 7 on [[Fedora_19|Fedora 19]] <u>ONLY</u>!  Although tested, use at your own risk. I cannot guarantee that it will work for your system or not cause any serious problems.<br />
 +
<br />
  
 +
==== Purpose ====
 +
The primary intent of the [http://www.amahi.org/apps/amahi-mail-system Amahi Mail System] is to allow you to use your Home Digital Assistant ([[Intro|HDA]]) as a mail server.
  
The Amahi Mail System is still under development.  It allows you to send/receive mail from your HDA.  There are some quirks depending on if you have a registered domain with a paid service provider (i.e. [http://www.godaddy.com godaddy], [http://www.hostgator.com HostGator])
+
* It allows you to send/receive mail from your [[Intro|HDA]].  There are some quirks depending on if you have a registered domain with a paid service provider (i.e. [http://www.godaddy.com GoDaddy], [http://www.hostgator.com Host Gator], etc).  With these services, there is typically what is called a MX record associated with the domain name.  This will allow you to send/receive mail as your hostname (i.e. myhda@home.com)
  
 +
* If you use the free ones (i.e. user.yourhda.com, [http://www.no-ip.org no-ip.org], etc), you will have to [[Masquerade_email_address|masquerade your email address]] as your ISP (i.e. myhda@yourisp.com).  This will ensure you can receive email replies from those you send from your [[Intro|HDA]].
  
Script download links:
+
==== Current Version ====
 +
1.05 ([[Fedora_19|Fedora 19]]) released January 1, 2014
  
32-bit: http://dl.getdropbox.com/u/1380867/32bit-virtual-mail-1.2.tar.gz<br />
+
==== Known Issues ====
64-bit:  http://dl.getdropbox.com/u/1380867/64bit-virtual-mail-1.2.tar.gz<br />
+
* During the configuration, the ClamAV definitions download sometimes takes too long. It can cause the setup to fail, depending on availability of their server.
 +
** The proposed work around is to run the ClamAV virus definition update after setup is complete.
 +
** Comment out line 164 (<code>/usr/bin/freshclam -v</code>) in ''mail-setup.sh'' script.
 +
** Run this separately after configuration is complete when you will see the notification ''You have 2 new messages.''
  
 +
==== Change Log ====
 +
* Upgraded to [[Amahi_7|Amahi 7]] on [[Fedora_19|Fedora 19]]
 +
* Added 32-bit binaries
 +
* Changed web page background color
 +
* Remove quota info from web pages
 +
* Enable port 587 for sending mail
 +
* Removed mail quota from Postfix configuration
 +
* Fixed certificate errors when using spaces
 +
* Streamlined uninstall script for better cleanup
 +
* Added script to update mail certificate
 +
* Inserted additional logging messages
 +
 +
==== Future Enhancements ====
 +
* Expand instructions to include how to configure mail clients
 +
* Incorporate a mail backup mechanism
 +
* Streamline code and validate form fields
 +
* Move mailbox data files to share (See [[Amahi_Mail_System#Tips|Tips]] below)
 +
 +
==== How to Install/Uninstall (Automated) ====
 +
* Special access must be requested to install [http://www.amahi.org/apps/amahi-mail-system Amahi Mail System].
 +
* Once granted, install/uninstall via the Applications tab in the Amahi Dashboard.
 +
 +
==== How to Install (Manual) ====
  
 
Here's the sequence of events to get the virtual email server up and running:
 
Here's the sequence of events to get the virtual email server up and running:
# Create a web app in Amahi named '''webmail'''.
+
# Restart your [[Intro|HDA]] so it's fresh for the install.  This is not required, just a recommendation.
# Open a terminal window, become '''root''', and navigate to <u>/var/hda/web-apps/webmail</u> directory.
+
# Open terminal [[Open_Terminal_as_root|as '''root''' user]], and create a web app in Amahi named '''ams''' (Amahi application [https://www.amahi.org/apps/web-apps Web App] provides this capability.).
# Download the script file (ensure you pick the correct one for your system) to this directory and extract it into the <u>html</u> directory of webmail.
+
# Navigate to '''''/var/hda/web-apps/ams''''' directory.
# From the <u>html</u> directory, run the '''host-update-virtual-mail-1.2.sh''' script.  This will check your hostname.  If it is not correct, you will be given an opportunity to change it.
+
# Download [https://dl.dropboxusercontent.com/u/1380867/mail-server-1.05.zip mail-server-1.05.zip] (sha1sum 4d5623d5d00a4d66512455deaec688fc49a34782) to this directory and extract it into '''''html''''' directory of '''''ams''''' (archive [http://dl.getdropbox.com/u/1380867/FilesList.html file list]).
# Once it completes, run the '''install-virtual-mail-1.2.sh''' script. The dependencies will be first and you must answer the prompt to continue.
+
# Ensure you recursively change ownership of the files to apache:users.
# Watch the script for errors. At 2 points, you will have to provide responses for the script to finish successfully.
+
# Need to make a directory called '''''elevated''''' in '''''ams'''''.  Copy mail-setup.sh and del-maildir.sh to that location.
# At the first prompt for testing the pop3 server, just type '''quit'''.
+
# Ensure mail-setup.sh and del-maildir.sh are executable.
# The second prompt you need to type '''ehlo localhost''', then if everything appears ok then type '''quit'''.
+
# Create the database and insert the data from the mail.sql file located in the '''''config''''' directory.
# Once the script is complete, note the user name and password.
+
# Navigate to <b><nowiki>http://ams</nowiki></b> in your favorite web browser and you should see the login page.
# Navigate to <u>http://webmail</u> and enter your login credentials.
+
# Enter credentials (admin/amahi) and choose Login to display the install page (See [[Amahi_Mail_System#Tips|Tips]] for how to change the login info).
# To uninstall, run the '''uninstall-virtual-mail-1.2.sh''' script.
+
# Complete all the required info.  Once finished, select the click the '''NEXT''' button and the data will be added to the database.
 +
# Next, a screen will appear with a '''INSTALL''' button, click it to begin.  You will also notice a log link so you can monitor the install.
 +
# Use your favorite mail client, [http://www.amahi.org/apps/roundcube Roundcube], [http://www.amahi.org/apps/atmail AtMail], or [http://www.amahi.org/apps/squirrelmail SquirrelMail] to access your new mail account.
 +
# Use the built-in tool to manage Virtual User information in the database.  [http://www.amahi.org/apps/dadabik DadaBIK], [http://www.amahi.org/apps/phpmyadmin phpMyAdmin], or [http://www.amahi.org/apps/adminer Adminer] can also be utilized.
 +
 
 +
===== Example Install Terminal Session =====
 +
<pre>su -
 +
cd /var/hda/web-apps/ams
 +
wget https://dl.dropboxusercontent.com/u/1380867/mail-server-1.05.zip
 +
mkdir -p elevated
 +
cd html
 +
unzip ../mail-server-1.05.zip
 +
chmod 755 *.sh
 +
chown -R apache:users * ../elevated
 +
cp mail-setup.sh ../elevated
 +
cp del-maildir.sh ../elevated
 +
hda-create-db-and-user mail
 +
mysql -umail -pmail mail < config/mail.sql</pre>
 +
 
 +
==== How to Uninstall (Manual) ====
 +
To uninstall, do the following:
 +
# Open terminal [[Open_Terminal_as_root|as '''root''' user]], and navigate to '''''/var/hda/web-apps/ams/html''''' directory.
 +
# Remove the database.
 +
# Ensure mail-remove.sh is executable.
 +
# From the '''''html''''' directory, run the script.  This may take a while to complete.
 +
# Remove the web app in Amahi named '''ams''' (Amahi application [https://www.amahi.org/apps/web-apps Web App] provides this capability.) and close the terminal window.
 +
 
 +
===== Example Uninstall Terminal Session =====
 +
<pre>su -
 +
cd /var/hda/web-apps/ams/html
 +
hda-create-db-and-user -d mail
 +
./mail-remove.sh</pre><br>
 +
 
 +
==== Add-Ons ====
 +
<u>Mailman</u><br>
 +
You can now add the Mailman software to your Amahi Mail System.  Follow the instructions at [http://wiki.amahi.org/index.php/Amahi_Mailman Amahi Mailman].
 +
 
 +
<u>FetchYahoo</u>
 +
Add capability to fetch Yahoo mail:
 +
* Download the latest [http://fetchyahoo.twizzler.org/ FetchYahoo]
 +
* Install instructions included
 +
 
 +
==== Tips ====
 +
* To permanently change your hostname from '''localhost.localdomain''', see this [http://www.labtestproject.com/using_linux/permanently_change_hostname_on_fedora article].
 +
 
 +
* You can change the Login Credentials for the integrated database manager/web-based installer by doing the following:
 +
** Open the Login-class.php file in the '''''/var/hda/web-apps/ams/html''''' directory
 +
** On lines 29 and 32, change to whatever works for you
 +
** Save and now you can log in using the new credentials
 +
 
 +
* Change the sender default email address format (i.e. root@hda.amahi.net) by following [[Masquerade_email_address|Masquerade email address]] tutorial.
 +
 
 +
* Update mail certificate
 +
** Should you need to update the mail certificates, use the mail-cert-update.sh script.
 +
** Prior to executing the script, you will want to update the values for Country, State, City, Organization, Organizational Unit, and Number of Days for the certificate to be valid.
 +
** Once complete, you can execute the script to update the mail server certificates.
 +
su -
 +
cd /var/hda/web-apps/ams/html
 +
./mail-cert-update.sh
 +
 
 +
* Move mailbox data files to share
 +
** <u>MUST</u> be accomplished prior to doing the install (Step #12).
 +
** Will ensure if you uninstall, mailbox data files will be preserved.
 +
** Create a new [[Storage_and_file_sharing#Step_2:_Create_Shares|share]] named <b>ams</b> in Amahi dashboard Shares tab.
 +
** Open terminal [[Open_Terminal_as_root|as '''root''' user]] and execute the following commands:
 +
cd /var/hda/web-apps/ams
 +
sed -i '57s|/home/vmail|/var/hda/files/ams|' html/mail-setup.sh;
 +
sed -i '65s|/home/vmail|/var/hda/files/ams|' html/mail-setup.sh;
 +
sed -i '74s|/home/vmail|/var/hda/files/ams|' html/users.php;
 +
sed -i '12s|/home/vmail|/var/hda/files/ams|' html/config/authmysqlrc;
 +
 
 +
====Troubleshooting====
 +
* Should your mail server hang up and stop working, you can most likely fix it with the <b>mail-stop.sh</b> and <b>mail-start.sh</b> scripts included in the app.  Open terminal [[Open_Terminal_as_root|as '''root''' user]] and do the following:
 +
<pre>cd /var/hda/web-apps/ams/html
 +
./mail-stop.sh
 +
./mail-start.sh</pre>
 +
 
 +
* If you get the message " warning: SASL authentication failure: No worthy mechs found."  [[Open_Terminal_as_root|open a terminal as '''root''']] and execute the following:
 +
yum install cyrus-sasl{,-plain}
 +
: Restart Postfix
 +
systemctl restart postfix
 +
<!--* Add '''NEW''' users to the foo.com domain (does not include any DNS MX records). Modify the '''mail''' database and substitute your information accordingly:
 +
*# In the '''users''' table, insert a new record with the following information...
 +
*#* ''user'':  <u>user@foo.com</u>
 +
*#* ''password'': choose 'ENCRYPT' for the function and enter the users password. (Alternatively, you can have the user enter their password)
 +
*#* ''quota'': do NOT edit this field (unless you know what you are doing)
 +
*# In the '''forwardings''' table, insert a new record for each forwarded email addresses to <u>user@foo.com</u>
 +
*# Run the command line below to set up the '''''/home/vmail/foo.com/user''''' mail files:
 +
{{Code|mailx -s Welcome user@foo.com < /var/hda/web-apps/ams/html/config/welcome.txt}}
 +
* Add an additional mail domain (does not include any DNS MX records).  Modify the ''mail'' database and substitute your information accordingly:
 +
*# Scenario - Creating a mail domain e.g. :
 +
*#* ''domain'' is: <u>bar.com</u>
 +
*#* ''server'' is: <u>foo.bar.com</u>
 +
*#* ''admin user'' is: <u>me@bar.com</u>
 +
*# In the mail mySQL database tables:
 +
*#* ''domain'':  add <u>bar.com</u>
 +
*#* ''transport'': add <u>bar.com</u>
 +
*#* ''user'':  add <u>me@bar.com</u>
 +
*#* ''forward'':  add <u>postmaster@bar.com</u>, and <u>abuse@bar.com</u> to <u>me@bar.com</u>
 +
*# Run the command line below to set up the '''''/home/vmail/bar.com/me''''' mail files:
 +
{{Code|mailx -s Welcome me@bar.com < /var/hda/web-apps/ams/html/config/welcome.txt}}
 +
* For every domain supported, the following either need to be added as users or forwarded.  Without them a site MAY end up on various spam block lists:
 +
{{Text|Text=postmaster@foo.com
 +
abuse@foo.com}}-->
 +
<!--* Some ISPs block port 25 for mail.  Thus a remote user would be able to retrieve mail, but not send mail.  To accommodate this, port 587 is used by email clients for sending mail.
 +
*# To enable port 587, edit '''''/etc/postfix/master.cf''''' and uncomment the line starting with "# submission"
 +
*# Reload postfix -->
 +
 
 +
==== Conclusion ====
 +
You should now be able to log in to your account. There will be 2 messages, one is a welcome and the other is a SPAM test.  Direct any questions or comments to [https://forums.amahi.org the forums].
  
  
You should now be in your account via webmail. There will be 2 messages, one is a welcome and the other is a SPAM test to show it's working. I forgot to mention that you can access the mail server from any email client as well within your network. Unfortunately, there is currently no front-end for administering accounts, so you will have to modify the database via phpMyAdmin or Adminer.  
+
<b>NOTE:</b>  These scripts were adapted from the [http://www.howtoforge.com/virtual-users-and-domains-with-postfix-courier-mysql-and-squirrelmail-fedora-18-x86_64 Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Fedora 18 x86_64)] tutorial written by [http://twitter.com/falko Falko Timme].
  
  
<b>NOTE:</b>  These scripts were adapted from a tutorial authored by Falko Timme at [http://howtoforge.net/virtual-users-domains-postfix-courier-mysql-squirrelmail-fedora-10 http://howtoforge.net/virtual-users-domains-postfix-courier-mysql-squirrelmail-fedora-10].
+
[[Category:Apps]]

Latest revision as of 00:50, 20 March 2015

Warning.png WARNING
This should only be attempted by advanced users.
It is still under development.


DISCLAIMER: This is for Amahi 7 on Fedora 19 ONLY! Although tested, use at your own risk. I cannot guarantee that it will work for your system or not cause any serious problems.

Purpose

The primary intent of the Amahi Mail System is to allow you to use your Home Digital Assistant (HDA) as a mail server.

  • It allows you to send/receive mail from your HDA. There are some quirks depending on if you have a registered domain with a paid service provider (i.e. GoDaddy, Host Gator, etc). With these services, there is typically what is called a MX record associated with the domain name. This will allow you to send/receive mail as your hostname (i.e. myhda@home.com).
  • If you use the free ones (i.e. user.yourhda.com, no-ip.org, etc), you will have to masquerade your email address as your ISP (i.e. myhda@yourisp.com). This will ensure you can receive email replies from those you send from your HDA.

Current Version

1.05 (Fedora 19) released January 1, 2014

Known Issues

  • During the configuration, the ClamAV definitions download sometimes takes too long. It can cause the setup to fail, depending on availability of their server.
    • The proposed work around is to run the ClamAV virus definition update after setup is complete.
    • Comment out line 164 (/usr/bin/freshclam -v) in mail-setup.sh script.
    • Run this separately after configuration is complete when you will see the notification You have 2 new messages.

Change Log

  • Upgraded to Amahi 7 on Fedora 19
  • Added 32-bit binaries
  • Changed web page background color
  • Remove quota info from web pages
  • Enable port 587 for sending mail
  • Removed mail quota from Postfix configuration
  • Fixed certificate errors when using spaces
  • Streamlined uninstall script for better cleanup
  • Added script to update mail certificate
  • Inserted additional logging messages

Future Enhancements

  • Expand instructions to include how to configure mail clients
  • Incorporate a mail backup mechanism
  • Streamline code and validate form fields
  • Move mailbox data files to share (See Tips below)

How to Install/Uninstall (Automated)

  • Special access must be requested to install Amahi Mail System.
  • Once granted, install/uninstall via the Applications tab in the Amahi Dashboard.

How to Install (Manual)

Here's the sequence of events to get the virtual email server up and running:

  1. Restart your HDA so it's fresh for the install. This is not required, just a recommendation.
  2. Open terminal as root user, and create a web app in Amahi named ams (Amahi application Web App provides this capability.).
  3. Navigate to /var/hda/web-apps/ams directory.
  4. Download mail-server-1.05.zip (sha1sum 4d5623d5d00a4d66512455deaec688fc49a34782) to this directory and extract it into html directory of ams (archive file list).
  5. Ensure you recursively change ownership of the files to apache:users.
  6. Need to make a directory called elevated in ams. Copy mail-setup.sh and del-maildir.sh to that location.
  7. Ensure mail-setup.sh and del-maildir.sh are executable.
  8. Create the database and insert the data from the mail.sql file located in the config directory.
  9. Navigate to http://ams in your favorite web browser and you should see the login page.
  10. Enter credentials (admin/amahi) and choose Login to display the install page (See Tips for how to change the login info).
  11. Complete all the required info. Once finished, select the click the NEXT button and the data will be added to the database.
  12. Next, a screen will appear with a INSTALL button, click it to begin. You will also notice a log link so you can monitor the install.
  13. Use your favorite mail client, Roundcube, AtMail, or SquirrelMail to access your new mail account.
  14. Use the built-in tool to manage Virtual User information in the database. DadaBIK, phpMyAdmin, or Adminer can also be utilized.
Example Install Terminal Session
su -
cd /var/hda/web-apps/ams
wget https://dl.dropboxusercontent.com/u/1380867/mail-server-1.05.zip
mkdir -p elevated
cd html
unzip ../mail-server-1.05.zip
chmod 755 *.sh
chown -R apache:users * ../elevated
cp mail-setup.sh ../elevated
cp del-maildir.sh ../elevated
hda-create-db-and-user mail
mysql -umail -pmail mail < config/mail.sql

How to Uninstall (Manual)

To uninstall, do the following:

  1. Open terminal as root user, and navigate to /var/hda/web-apps/ams/html directory.
  2. Remove the database.
  3. Ensure mail-remove.sh is executable.
  4. From the html directory, run the script. This may take a while to complete.
  5. Remove the web app in Amahi named ams (Amahi application Web App provides this capability.) and close the terminal window.
Example Uninstall Terminal Session
su -
cd /var/hda/web-apps/ams/html
hda-create-db-and-user -d mail
./mail-remove.sh


Add-Ons

Mailman
You can now add the Mailman software to your Amahi Mail System. Follow the instructions at Amahi Mailman.

FetchYahoo Add capability to fetch Yahoo mail:

  • Download the latest FetchYahoo
  • Install instructions included

Tips

  • To permanently change your hostname from localhost.localdomain, see this article.
  • You can change the Login Credentials for the integrated database manager/web-based installer by doing the following:
    • Open the Login-class.php file in the /var/hda/web-apps/ams/html directory
    • On lines 29 and 32, change to whatever works for you
    • Save and now you can log in using the new credentials
  • Change the sender default email address format (i.e. root@hda.amahi.net) by following Masquerade email address tutorial.
  • Update mail certificate
    • Should you need to update the mail certificates, use the mail-cert-update.sh script.
    • Prior to executing the script, you will want to update the values for Country, State, City, Organization, Organizational Unit, and Number of Days for the certificate to be valid.
    • Once complete, you can execute the script to update the mail server certificates.
su -
cd /var/hda/web-apps/ams/html
./mail-cert-update.sh
  • Move mailbox data files to share
    • MUST be accomplished prior to doing the install (Step #12).
    • Will ensure if you uninstall, mailbox data files will be preserved.
    • Create a new share named ams in Amahi dashboard Shares tab.
    • Open terminal as root user and execute the following commands:
cd /var/hda/web-apps/ams
sed -i '57s|/home/vmail|/var/hda/files/ams|' html/mail-setup.sh;
sed -i '65s|/home/vmail|/var/hda/files/ams|' html/mail-setup.sh;
sed -i '74s|/home/vmail|/var/hda/files/ams|' html/users.php;
sed -i '12s|/home/vmail|/var/hda/files/ams|' html/config/authmysqlrc;

Troubleshooting

  • Should your mail server hang up and stop working, you can most likely fix it with the mail-stop.sh and mail-start.sh scripts included in the app. Open terminal as root user and do the following:
cd /var/hda/web-apps/ams/html
./mail-stop.sh
./mail-start.sh
  • If you get the message " warning: SASL authentication failure: No worthy mechs found." open a terminal as root and execute the following:
yum install cyrus-sasl{,-plain}
Restart Postfix
systemctl restart postfix

Conclusion

You should now be able to log in to your account. There will be 2 messages, one is a welcome and the other is a SPAM test. Direct any questions or comments to the forums.


NOTE: These scripts were adapted from the Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Fedora 18 x86_64) tutorial written by Falko Timme.