Archive

Articles taggués ‘Mail’

Email notifications using Gmail SMTP server on Linux

13/04/2016 Comments off

Send email notifications using Gmail SMTP

email notifications gmailUsing Gmail SMTP: Suppose you want to configure a Linux app to send out email messages from your server or desktop. The email messages can be part of email newsletters, status updates (e.g., Cachet), monitoring alerts (e.g., Monit), disk events (e.g., RAID mdadm), and so on. While you can set up your own outgoing mail server to deliver messages, you can alternatively rely on a freely available public SMTP server as a maintenance-free option.

One of the most reliable free SMTP servers is from Google’s Gmail service. All you have to do to send email notifications within your app is to add Gmail’s SMTP server address and your credentials to the app, and you are good to go.

One catch with using Gmail’s SMTP server is that there are various restrictions in place, mainly to combat spammers and email marketers who often abuse the server. For example, you can send messages to no more than 100 addresses at once, and no more than 500 recipients per day. Also, if you don’t want to be flagged as a spammer, you cannot send a large number of undeliverable messages. When any of these limitations is reached, your Gmail account will temporarily be locked out for a day. In short, Gmail’s SMTP server is perfectly fine for your personal use, but not meant for commercial bulk emails.

With that being said, let me demonstrate how to use Gmail’s SMTP server in Linux environment.

Google Gmail SMTP Server Setting

If you want to send emails from your app using Gmail’s SMTP server, you need to adjust the security setting of the Gmail account to be used. Go to the Google account settings, and enable the option to allow less secure apps, which is off by default.

Then you will need to provide your app with the following details.

  • Outgoing mail server (SMTP server): smtp.gmail.com
  • Use authentication: yes
  • Use secure connection: yes
  • Username: your Gmail account ID (e.g., « alice » if your email is alice@gmail.com)
  • Password: your Gmail password
  • Port: 587 (TLS) or 465 (SSL)

Exact configuration syntax may vary depending on apps. In the rest of this tutorial, I will show you several useful examples of using Gmail SMTP server in Linux.

Send Emails from the Command Line

As the first example, let’s try the most basic email functionality: send an email from the command line using Gmail SMTP server. For this, I am going to use a command-line email client called Mutt.

First, install Mutt as follows.

For Debian-based system:

$ sudo apt-get install mutt

For Red Hat based system:

$ sudo yum install mutt

Create a mutt configuration file (~/.muttrc) and specify in the file Gmail SMTP server information as follows. Replace <gmail-id> with your own Gmail ID. Note that this configuration is for sending emails only (not receiving emails).

$ vi ~/.muttrc

set from = "<gmail-id>@gmail.com"
set realname = "Dan Nanni"
set smtp_url = "smtp://<gmail-id>@smtp.gmail.com:587/"
set smtp_pass = "<gmail-password>"

Now you are ready to send out an email using mutt:

$ echo "This is an email body." | mutt -s "This is an email subject" alice@yahoo.com

To attach a file in an email, use « -a » option:

$ echo "This is an email body." | mutt -s "This is an email subject" alice@yahoo.com -a ~/test_attachment.jpg

22239850784_5fb0988075_c

Using Gmail SMTP server means that the emails appear as sent from your Gmail account. In other words, a recipient will see your Gmail address as the sender’s address. If you want to use your domain as the email sender, you need to use Gmail SMTP relay service instead.

Another note is that if you are concerned about placing your SMTP password in the plain-text .muttrc file, you can encrypt the password using GnuPG.

Lire la suite…

Installation Serveur Mail Postfix, Amavisd, Mysql, Spamassassin, Dspam, Dovecot

23/09/2015 Comments off

Ce tutoriel a été intégralement repris du site  http://www.starbridge.org et a été réalisé par tonio. Il est distribué sous licence creativecommons  Creative Commons License

Cet article, initié en 2007, est mis à jour régulièrement.
Le système sur lequel est basé ce document est une DEBIAN stable (Wheezy).
Le tuto est aussi entièrement compatible avec la version Testing (Jessie).

Ce tuto fonctionne également sous Ubuntu mais certains paquets présentent de légères différences. On essaiera de les indiquer si possible.

Mise à jour du 5/5/2015

Table des matières

Préparation de l’environnement

On prendra comme base pour l’exemple le domaine starbridge.org et le hostname du serveur de mail sera spike.

On met le système à jour :

aptitude update
aptitude full-upgrade

On vérifie les fichiers :

/etc/hostname : spike.starbridge.org
/etc/hosts : 127.0.0.1    spike.starbridge.org localhost.localdomain localhost spike

Lire la suite…

Configuration d’un serveur dédié de A à Z

17/07/2015 Comments off

Installation, configuration et administration d’un serveur dédié

debianCes tutoriaux ont été réalisés sous Debian (versions Etch 4.0 et Lenny 5.0) mais peuvent être transposés à d’autres distributions Linux, notamment Ubuntu. Ils sont applicables aux serveurs dédiés 1&1, Dedibox, OVH, Amen, et bien d’autres.

warning Tous les tutoriaux sont basés sur un serveur nommé test.alsacreations.com pour lequel nous disposons d’un utilisateur dew et d’un accès root (super-administrateur), chacun avec leur propre mot de passe.

Nous partons de l’idée d’obtenir un serveur web avec tout ce qu’il faut pour héberger plusieurs domaines et sites. Vous pouvez tout configurer à la main ou bien faire confiance à un panel d’administration.

Liste complète sans panel web

idee Ces tutoriaux conviennent à l’installation complète d’un serveur

  1. Première connexion : SSH, accès root et bases
  2. Apache et PHP : le serveur web
  3. MySQL : les bases de données
  4. Proftpd : le serveur FTP
  5. Postfix : le serveur mail POP3 et SMTP
  6. Sauvegarde automatique : avec backup-manager et export FTP
  7. Sécurisation : les règles de base, un firewall avec iptables, fail2ban…
  8. Bind : exécuter le serveur DNS en chroot
  9. Monitoring : garder un oeil sur son serveur grâce à monit et logwatch
  10. Roundcube : un webmail léger et rapide

Liste complète avec panel d’administration DTC

dtclogo

idee Si vous choisissez d’installer le panel d’administration DTC, suivez ces tutoriels. DTC se chargera de la configuration du reste des services.

  1. Première connexion : SSH, accès root et bases
  2. Bind : exécuter le serveur DNS en chroot
  3. Sécurisation : les règles de base, un firewall avec iptables, fail2ban…
  4. Panel DTC : pour installer et gérer les services web, ftp, mysql, e-mail, dns…
  5. Monitoring : garder un oeil sur son serveur grâce à monit et logwatch
  6. Sauvegarde automatique : backup-manager et export FTP
  7. Roundcube : un webmail léger et rapide

Attention : nous préconisons désormais l’utilisation du panel ISPConfig, en lieu et place du panel DTC. Il est tout aussi simple à installer et à utiliser. Veuillez vous référer à sa documentation.

Fail2ban, POSTFIX and SPAM

28/01/2014 Comments off

source: deribin.com

Very simple solution:
1) add rule to /etc/fail2ban/jail.conf:

[spam] enabled = true
filter = spam
action = iptables[name=SPAM, port=smtp, protocol=tcp] sendmail-whois[name=SPAM, dest=email@your.doamin.com, sender=fail2ban@your.domain.com] logpath = /var/log/mail.log
bantime = 3600
ignoreip = 127.0.0.1 xxx.xxx.xxx.xxx/xx
maxretry = 2

Lire la suite...

MailRecent (Mail Plugin for Mac OS X)

28/01/2014 Comments off

Source: Gregory F. Welch

Adds « Copy to Recent, » « Move to Recent, » and « Go to Recent » menu items to Apple’s Mail application. These menu items contain dynamically-updated lists of recently used mailboxes. The number of mailboxes kept in the list is determined by the « Number of Recent Items » setting for Documents in the Appearance panel of the OS X System Preferences.

screenshot

 

Usage

Once installed (see instructions below) as you drag or option-drag a message to a mailbox, that mailbox should then appear under

  • « Copy to Recent » and « Move to Recent » submenus under the « Messages » menu, and
  • a « Go to Recent » submenu under the « Mailboxes » menu.

Similarly if you use Mail’s built-in « Move To » or « Copy To » menus to move a message to a mailbox, that mailbox should then appear in the lists. The recent mailboxes will be sorted alphabetically, the same as OS X does for recent documents. (You can change the sorting behavior using the Terminal application as described below.)

Lire la suite…

Categories: Logiciel Tags: , ,

Postfix + fail2ban = win

28/01/2014 Comments off
source: http://blog.dp.cx/25/postfix-fail2ban-win

Recently, I had to lease a new server. My old one was ok, but it was 5 years old, and showing it’s age. The most recent bout of problems was due to postfix, and a specific domain that I host mail for.

I had previously set up Policyd in an attempt to stop the influx of spam before it ever hit the server, but it wasn’t doing anything at this point. So approximately 800 messages per minute were getting directly to Postfix, and then running queries against MySQL (I use virtual maps for users, aliases, domains, etc). 99% of these messages were to non-existant users, so Postfix would bounce them. But the little 2.0GHz Celeron couldn’t handle it. The load shot up to 8 for around 3 weeks, and stayed there. I wish the fail2ban idea had come to me sooner… Lire la suite…

Supervision de postfix via mailgraph avec le plugin check_mailstat.pl via Nagios/Centreon

28/01/2014 Comments off

Source:  l’admin sous GNU/Linux – blog libreCentreon_graph_mailstat_home

 

Voici une procédure permettant de contrôler l’activité d’un serveur de messagerie postfix via Nagios / Centreon.

Pour cela nous allons utiliser le plugins check_mailstat.pl avec une petite adaptation du script afin de le rendre compatible avec la génération de graphe sous Centreon.

Le plugin check_mailstat.pl va récupérer depuis des données depuis mailgraph qui permet de générer des graphes via RRDTool

Tout d’abord, il faut installer Mailgraph sur l’hôte à superviser, ici une Debian.

Installation de Mailgraph

aptitude install mailgraph

Si l’installation ne vous a pas poser les questions propres au paramétrage, lancer :

dpkg-reconfigure mailgraph

Voici les questions et réponse à fournir :

Mailgraph doit-il être lancé au démarrage ? OUI

Fichier de journalisation à utiliser par mailgraph : /var/log/mail.log (à adapter)

Faut-il compter les courriels entrants comme des courriels sortants ? NON (J’utilise Amavis, donc j’ai choisi cette option, encore une fois à adapter.

Lire la suite…

Thunderbird/Change account order

09/01/2014 Comments off

To change the order of the accounts in Thunderbird simply edit

~/.thunderbird/<your profile>/prefs.js in GNU/Linux,
C:\Documents and Settings\<your profile>\Application Data\Thunderbird\Profiles\****.default\prefs.js in Microsoft Windows XP,

Lire la suite…

ISPConfig 3 + Squeeze – SSL/TLS 465 SMTP Fail

07/01/2014 Comments off

ispconfigSource: howtoforge.com

Hi there.

New install of ISPConfig 3 on Debian Squeeze [previously on Lenny]

Created using: http://www.ispconfig.org/news/tutorial-the-perfect-server-debian-squeeze-debian-6-0-with-bind-courier-ispconfig-3/

Previous server used:

Port: 465
Connection security: SSL/TLS
Authentication method: normal password

If I try to use these setting on this fresh install [complete format with previous back up files stored on a seperate drive] I get the following error:

Sending of message failed.

The message could not be sent because connecting to SMTP server mail.myserver.com (changed from real name – error has correct name) failed. The server may be unavailable or is refusing SMTP connections. Please verify that your SMTP server settings are correct and try again, or contact the server administrator.

I can send using:

Port: 25
Connection security: STARTTLS
Authentication method: normal password

No errors appear in mail.log or mail.err

I’ve compared the master.cf pre/post [original/current]

Differing section appears to be:

Original

smtp inet n - - - - smtpd
submission inet n - - - - smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticate d,reject
-o milter_macro_daemon_name=ORIGINATING
smtps inet n - - - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticate d,reject
-o milter_macro_daemon_name=ORIGINATING

Current

smtp inet n - - - - smtpd
#submission inet n - - - - smtpd
# -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticate d,reject
# -o milter_macro_daemon_name=ORIGINATING
#smtps inet n - - - - smtpd
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticate d,reject
# -o milter_macro_daemon_name=ORIGINATING

main.cf has a couple of minor differences

Original

smtpd_tls_CAfile = /etc/postfix/cert.pem

*This line is missing in the current main.cf

Current

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

*These lines do not appear in the original main.cf

No firewall rules are set to block ports.

hopefully I’ve provided enough detail.

Categories: Logiciel Tags: , ,

Create DNS Service Location (SRV) records for the Exchange Autodiscover service

07/01/2014 Comments off

Source: Upwards with SBS

In earlier blog posts I’ve discussed other DNS records such as the TXT SPF record.  This is a new but very important record that you will want in place for your domain.

Here’s a list of great resources that describe this in detail and include guidance to manually create and publish the record to whomever is hosting your DNS records for the domain.