Gmail Archives - Justin Silver https://www.justinsilver.com/tag/gmail/ Technology, Travel, and Pictures Wed, 07 Sep 2016 21:02:47 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.1 https://www.justinsilver.com/wp-content/uploads/2013/06/cropped-apple-touch-icon-160x160.png Gmail Archives - Justin Silver https://www.justinsilver.com/tag/gmail/ 32 32 Send Emails on Mac OS X with Postfix and a Gmail Relay https://www.justinsilver.com/technology/osx/send-emails-mac-os-x-postfix-gmail-relay/?utm_source=rss&utm_medium=rss&utm_campaign=send-emails-mac-os-x-postfix-gmail-relay https://www.justinsilver.com/technology/osx/send-emails-mac-os-x-postfix-gmail-relay/#comments Wed, 07 Sep 2016 20:42:27 +0000 https://www.justinsilver.com/?p=4248 A quick howto setup Mac OS X and Postfix to use Gmail as a relay. Everything will need to be executed as root using sudo. If you just need to send emails try running...

The post Send Emails on Mac OS X with Postfix and a Gmail Relay appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

A quick howto setup Mac OS X and Postfix to use Gmail as a relay. Everything will need to be executed as root using sudo. If you just need to send emails try running sudo postfix start, and make sure to check your spam for emails – they will likely be flagged as they originate from a local mail server.

SASL Authentication

Connecting to the Gmail SMTP server requires both SSL and authentication. To set up authentication you will need to edit the /etc/postfix/sasl_passwd file.

sudu vi /etc/postfix/sasl_passwd

Update the contents to include the following. Note that enclosing hostnames with square brackets – [] – tells Postfix to avoid doing an MX lookup. Make sure to replace EMAIL with your email address, and PASSWORD with your Gmail password, properly escaping any colons in it.

[smtp.gmail.com]:587 [email protected]:PASSWORD

Use the postmap command to update the SASL credentials in Postfix.

sudo postmap /etc/postfix/sasl_passwd

Postfix Relay Configuration

Next we need to edit the Postfix configuration found in /etc/postfix/main.cf.

sudo vi /etc/postfix/main.cf

I was not able to route mail to the Gmail SMTP servers over IPv6, so force only IPv4 connections by searching for the inet_protocols key and updating the value.

inet_protocols = ipv4

If any of the following keys already exist in your configuration comment them out, and include the following at the bottom of the config file.

# Gmail SMTP relay
relayhost = [smtp.gmail.com]:587

# Enable SASL authentication in the Postfix SMTP client.
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_sasl_mechanism_filter = AUTH LOGIN

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls = yes
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom

Restart Postfix & Test

Restart Postfix as root, then send a test email.

sudo postfix stop && sudo postfix start
date | mail -s "Test Email" [email protected]

If you don’t receive the test email, check the Postfix queue by running mailq or looking at the contents of /var/log/mail.log. Any errors that mention “SASL authentication failed” indicate that you may have entered an incorrect email/password combination, forgot to run postmap after updating the credentials, or need to Turn On Access for less secure apps in Gmail for your account.

The post Send Emails on Mac OS X with Postfix and a Gmail Relay appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/osx/send-emails-mac-os-x-postfix-gmail-relay/feed/ 25
Google Apps + Trac Integration Using email2trac https://www.justinsilver.com/technology/linux/google-apps-trac-integration-using-email2trac/?utm_source=rss&utm_medium=rss&utm_campaign=google-apps-trac-integration-using-email2trac https://www.justinsilver.com/technology/linux/google-apps-trac-integration-using-email2trac/#respond Sun, 09 Jun 2013 08:14:42 +0000 http://justin.ag/?p=3027 I have been using Trac for viewing my Subversion source repository and some ticketing, however I wanted to be able to integrate email directly to the ticketing system. The second part of my setup...

The post Google Apps + Trac Integration Using email2trac appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

I have been using Trac for viewing my Subversion source repository and some ticketing, however I wanted to be able to integrate email directly to the ticketing system. The second part of my setup is the use of Google Apps to host our mail domain, so the easiest way to set this up was to create a new user ([email protected] / p@ssword in the example below).

My development server is running CentOS 5.8, Trac 0.12, and python2.7 (although the site-packages for CentOS are still in /var/lib/python2.4/site-packages. Because of this it was necessary to add the PYTHONPATH to the environment when calling email2trac.

The installation instructions for email2trac can be found on its homepage here, or here’s the quick version:

cd ~
wget ftp://ftp.sara.nl/pub/outgoing/email2trac.tar.gz
tar xvf email2trac.tar.gz
cd email2trac-*
./configure
make
make install

The configuration information for email2trac is located in /usr/local/etc/email2trac.conf. I made a few changes to the default configuration as you can see below, or check out the default configuration.

[DEFAULT]
project: /var/trac/project
debug: 0 
black_list: MAILER-DAEMON@
drop_spam : 1
drop_alternative_html_version: 1
email_quote: >
html2text_cmd:
ignore_trac_user_settings: 0
inline_properties: 1
reply_all : 0
spam_level: 5
strip_quotes: 1
strip_signature: 1
ticket_update: 1
ticket_update_by_subject: 1
umask: 022
verbatim_format: 1

[other_project]
project: /var/trac/other_project

On my system I also needed to do a custom build of MySQL-python to get it into the proper PYTHONPATH. With my default python set to 2.7, I ran the following:

cd ~
yum install php-imap python-devel mysql-devel
wget http://sourceforge.net/projects/mysql-python/files/latest/download
cd MySQL-python*
python setup.py install

Note that above on my system I actually only installed mysql-devel.x86_64 due to a conflict in the i386 version.

Next I used the following PHP script to import message from the Trac Google Apps user and process them into Trac one at a time. Due to the different environment I had to set the PYTHONPATH using putenv() so that email2trac would run. This file was saved as /var/trac/gmail2trac.php.

<?php
// Connect to the Google Apps / Gmail account
$mailbox = imap_open("{imap.googlemail.com:993/ssl}INBOX", "[email protected]", "p@ssword");
// Get all unread emails
$mail = imap_search($mailbox, "UNSEEN");
if ( !empty($mail) ){
        // This is required on CentOS to find the Trac egg
        putenv("PYTHONPATH=/usr/lib/python2.4/site-packages");
        // Process each email
        foreach ($mail as $id){
                // Save the email contents to a temp file
                imap_savebody($mailbox, '/tmp/gmail2trac.txt', $id);
                // Import into Trac via email2trac
                system('/usr/local/bin/email2trac -f /usr/local/etc/email2trac.conf -p project < /tmp/gmail2trac.txt');
                // Mark as read
                imap_setflag_full($mailbox, $id, "\\Seen");
        }
}
// Close connection
imap_close($mailbox);
?>

Note that if you want to reprocess any emails, all you need to do is log in as the Trac user and mark the message as unread.

Lastly to import on a schedule – I opted for a check every 5 minutes – just setup a cron job via crontab -e.

*/5 * * * * php /var/trac/gmail2trac.php

The post Google Apps + Trac Integration Using email2trac appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/linux/google-apps-trac-integration-using-email2trac/feed/ 0