# Fetchmail and sendmail for Google Gmail account



## gpw928 (Aug 7, 2017)

Hi,

Has anyone got fetchmail configured to fetch mail from a gmail account (POP3 or IMAP)?

If, so I'd really appreciate some advice, and a look at the .fetchmailrc file.

Beyond that, teaching sendmail to post to Google's SMTP servers is the next project, so any advice on that subject would also be appreciated.

Cheers,


----------



## aragats (Aug 7, 2017)

I'm using mail/isync for IMAP, here is my ~/.mbsyncrc:
	
	



```
IMAPAccount gmail
Host imap.gmail.com
User my_user@gmail.com
Pass my_secret_password
SSLType IMAPS
CertificateFile /usr/local/share/certs/ca-root-nss.crt
IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
# The trailing "/" is important
Path ~/my_local_mail/
Inbox ~/my_local_mail/inbox

Sync All
Expunge Both

Channel gmail-inbox
Master ":gmail-remote:INBOX"
Slave ":gmail-local:inbox"
Create Both
SyncState *

Channel gmail-drafts
Master ":gmail-remote:[Gmail]/Drafts"
Slave ":gmail-local:drafts"
Create Both
SyncState *

Channel gmail-sent
Master ":gmail-remote:[Gmail]/Sent Mail"
Slave ":gmail-local:sent"
Create Both
SyncState *

Channel freebsd
Master ":gmail-remote:freebsd"
Slave ":gmail-local:freebsd"
Create Both
SyncState *

Group my_default_group
Channel gmail-inbox
Channel gmail-sent
Channel freebsd
```
For sending emails I use a very simple mail/ssmtp. My /usr/local/etc/ssmtp/ssmtp.conf:
	
	



```
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=my_user@gmail.com

# The place where the mail goes. The actual machine name is required
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=my_domain.com

# The full hostname
hostname=my_host_name

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES
UseSTARTTLS=YES

AuthMethod=LOGIN
AuthUser=my_users@gmail.com
AuthPass=my_secret_password
```


----------



## gpw928 (Aug 9, 2017)

Hi,

Just after posting, I got fetchmail to work with ~/.fetchmailrc:


```
set logfile "/home/phil/.fetchmail/fetchmail.log"
set postmaster "phil"
set no bouncemail
set properties ""
poll pop.gmail.com
  with no dns
  with proto POP3
  user "my.name@gmail.com"
  pass "**********"
  is phil here
options
  warnings 3600
  antispam 571 550 501 554
  no keep
  ssl
  sslfingerprint "3A:E4:20:C9:D0:78:3F:DE:F3:75:06:E1:DA:AE:44:05"
  sslcertck
  sslcertfile /usr/local/share/certs/ca-root-nss.crt
```
Didn't play too much with all the ssl things, no not entirely sure how many were required.

I had to login to my Google account and enable less secure apps.

I then tried isync, and had to add a newline before the IMAPStore section in ~/.mbsyncrc above.

Then "mbsync -a" worked.  Thanks.  That's saved as an option.

Gmail does not use a traditional mailbox, but keeps one message per file.  That's an annoyance.

Sadly, sendmail won't talk to google out of the box.  It complains about sendmail configuration stuff required by Google mail servers:


```
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
```

It seems that my choices are:

use isync and ssmtpd and get a new email reader; or
use fetchmail and teach sendmail how to use SASL.
Currently installing a fresh FreeBSD 11.1 vm to work on the latter...

Cheers,


----------

