Author Topic: Pine Email Program With Ssl  (Read 10796 times)

ensign

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Pine Email Program With Ssl
« Reply #30 on: April 15, 2006, 03:35:40 am »
Quote
finally got fetchmail, procmail and pine to work well together. now I need to get msmtp to work.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=123270\"][{POST_SNAPBACK}][/a][/div]

It was a long time ago when i got this going so forgive me if i miss anything.

1. in your .pinerc you must have
Code: [Select]
.pinerc:sendmail-path=/home/QtPalmtop/bin/msmtp-enqueue.sh    
2. I think i had to modify the msmtp scripts. here is my msmtp-enqueue.sh
Code: [Select]
#!/bin/sh

QUEUEDIR=$HOME/.msmtpqueue

# Set secure permissions on created directories and files
umask 077

# Change to queue directory (create it if necessary)
if [ ! -d "$QUEUEDIR" ]; then
    mkdir -p "$QUEUEDIR" || exit 1
fi
cd "$QUEUEDIR" || exit 1

# Create new unique filenames of the form
# MAILFILE:  ccyy-mm-dd-hh.mm.ss[-x].mail
# MSMTPFILE: ccyy-mm-dd-hh.mm.ss[-x].msmtp
# where x is a consecutive number only appended if you send more than one
# mail per second.
BASE="`date +%Y-%m-%d-%H.%M.%S`"
if [ -f "$BASE.mail" -o -f "$BASE.msmtp" ]; then
    TMP="$BASE"
    i=1
    while [ -f "$TMP-$i.mail" -o -f "$TMP-$i.msmtp" ]; do
  i=`expr $i + 1`
    done
    BASE="$BASE-$i"
fi
MAILFILE="$BASE.mail"
MSMTPFILE="$BASE.msmtp"

# Write command line to $MSMTPFILE
echo "$@" > "$MSMTPFILE" || exit 1

# Write the mail to $MAILFILE
cat > "$MAILFILE" || exit 1

# If we are online, run the queue immediately.
# Replace the test with something suitable for your site.
ping -c 1 www.google.com > /dev/null
if [ $? -eq 0 ]; then
    msmtp-runqueue.sh > /dev/null &
fi

exit 0
3. Also here is my msmtp-runqueue.sh
Code: [Select]
QUEUEDIR="$HOME/.msmtpqueue"
LOCKFILE="$QUEUEDIR/.lock"
MAXWAIT=120

# wait for a lock that another instance has set
SECONDS=0
while [ -e "$LOCKFILE" -a "$SECONDS" -lt "$MAXWAIT" ]; do
    sleep 1
    SECONDS="`expr "$SECONDS" + 1`"
done
if [ -e "$LOCKFILE" ]; then
    echo "Cannot use $QUEUEDIR: waited $MAXWAIT seconds for"
    echo "lockfile $LOCKFILE to vanish, giving up."
    echo "If you are sure that no other instance of this script is"
    echo "running, then delete the lock file."
    exit 1
fi

# change into $QUEUEDIR
cd "$QUEUEDIR" || exit 1

# check for empty queuedir
if [ "`echo *.mail`" = '*.mail' ]; then
    echo "No mails in $QUEUEDIR"
    exit 0
fi

# lock the $QUEUEDIR
touch "$LOCKFILE" || exit 1

# process all mails
for MAILFILE in *.mail; do
    echo "*** Sending $MAILFILE..."
    MSMTPFILE="`echo $MAILFILE | sed -e 's/mail/msmtp/'`"
    if [ ! -f "$MSMTPFILE" ]; then
  echo "No corresponding file $MSMTPFILE found"
  echo "FAILURE"
  continue
    fi
    msmtp -t `cat "$MSMTPFILE"` < "$MAILFILE"
    if [ $? -eq 0 ]; then
  rm "$MAILFILE" "$MSMTPFILE"
  echo "$MAILFILE sent successfully"
    else
  echo "FAILURE"
    fi
done

# remove the lock
rm -f "$LOCKFILE"

exit 0

4. Also my .msmtprc
Code: [Select]
defaults
logfile /mnt/card/temp/msmtp.log

account googlemail
host smtp.gmail.com
from @gmail.com
port 587
auth on
user
password
tls on

account default:googlemail

I had to use google because my isp would not allow me to send mails using their smtp server if i was not connected to their service. no good if you are on the road. you may have the same problem.

bam

  • Hero Member
  • *****
  • Posts: 1213
    • View Profile
    • http://thegrinder.ws
Pine Email Program With Ssl
« Reply #31 on: April 15, 2006, 10:27:47 pm »
cool, thanks. as for getting my email, I have my own server so no worries there, except for my work which borks the data going out or in, not sure which one.
SL-C3100 current: Stock/Tetsu 18h
Socket BT CF Card
Linksys WCF-12 802.11b/Cheapie USB Ethernet

The Grinder