0

I am using fetchmail and procmail to forward email to a gmail account. I am using Mac Terminal.

Here is my .fetchmailrc:

set no bouncemail
poll outlook.office365.com with protocol imap
port 993
auth password
user user@domain.com password password
ssl
sslfingerprint "<Correct Fingerprint - not sure if I should copy this here>"
sslcertpath /Users/myuser/.certs
keep
no rewrite
mda "/usr/local/bin/procmail -f %F -d %T";

and here is my .procmailrc file:

VERBOSE=yes
:0
! myusername@gmail.com

When I run fetchmail -vv everything seems to work fine, it finds the one unread email in the email account I am fetching from. And the last thing in the output under procmail is:

procmail: Executing "/usr/sbin/sendmail,-oi,myusername@gmail.com"

No apparent errors are listed.

However, nothing is showing up in my gmail account?

  • 2
    If I read correctly, you are using a Mac. I seem to recall that it is necessary to do some configuration in order to use sendmail. Perhaps benjaminrojas.net/… will provide some information. – KevinO Jun 7 '17 at 21:05
  • 1
    You should see the unsent/queued messages by executing sudo postqueue -p. If you're at work, it may be easier to configure Postfix to use an internal relayhost/smart-host. You would not need to set the SASL connection as noted in the link from @KevinO comment if that is the case. – Deathgrip Jun 7 '17 at 22:00
  • Is there a reason you want to run this on your own computer? It would make more sense to configure this directly in Gmail. My understanding is that they support this. See e.g. support.google.com/mail/answer/21289 – tripleee Jun 8 '17 at 7:01
  • @tripleee - unfortunately Gmail can only fetch via POP and my work email only allows IMAP fetching and will not do automatic forwarding, hence this complicated work around. – Amanda Jun 8 '17 at 12:23
  • Thanks for the other comments, if the below by @thrig does not work I will look into the configuring link and/or internal relayhost, Thanks for taking the time – Amanda Jun 8 '17 at 12:25
0

Does it have to be procmail and the Apple mail transport agent, or could you instead lob things over to ssmtp? E.g. with MacPorts (install details will likely be very similar under Fink and Homebrew)

$ sudo port install ssmtp
...

And then configure ssmtp via /opt/local/etc/ssmtp/ssmtp.conf (or wherever Fink or Homebrew hide that file) with something like

root=FIXME@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=localhost
UseTLS=Yes
UseSTARTTLS=Yes
AuthUser=FIXME@gmail.com
AuthPass=Hunter2
FromLineOverride=no

And then setup your fetchmailrc with something like

...
mda "/opt/local/sbin/ssmtp FIXME"

This if all goes well should cause fetchmail to deliver to ssmtp and that to gmail.

  • Will try this ASAP, doesn't NEED to be procmail, that's just what I had found by searching. – Amanda Jun 8 '17 at 12:24
  • So this definitely "worked", though maybe not in the way I hoped. And that is definitely my fault for not being clear from the get go. If one IS able to get gmail to fetch mail, then when the mail comes in you see it as coming from "Sender@sendersdomain.com". However, with this process the email comes from me, FIXME@gmail.com, rather than the original sender. I apologize for taxing your time further, particularly if it is not possible, but do you know if what I am asking for is possible with this set up (maybe it wasn't with procmail either...) – Amanda Jun 8 '17 at 19:31
  • Changing FromLineOverride=yes gets half way there, now the email appears to come from SENDER NAME <FIXME@gmail.com> rather than FIX ME <FIXME@gmail.com>. But still not quite what I was hoping. – Amanda Jun 8 '17 at 19:58
  • Try also removing the root= line as the ssmtp.conf.sample configuration indicates the presence of that causes rewriting, which my config has as I'm lobbing different things as if from me through gmail. – thrig Jun 8 '17 at 20:11
  • Apologies for slow replies, have been at this most of the morning again. This did not work. I also tried to abandon ssmtp and go back to procmail following the comments above - I was able to configure sendmail appropriately but actually the result was the same - mail came to gmail as if from ME rather than from original sender. Maybe this is just not fixable, but it feels like people are able to redirect email so it should be doable. Happy for solutions using either procmail or ssmtp. I will keep looking around though if anyone has suggestions I am all ears. – Amanda Jun 9 '17 at 14:44
0

For future reference, both the comment from @KevinO and the answer from @thrig worked in that emails are now showing up in my gmail (albeit they look like they come from myusername@gmail.com rather than original sender, but that is another problem).

For those wanting to use procmail/postfix - As an update, to configure sendmail to send from gmail on OSX Sierra the instructions are a little different than the link that @KevinO provided:

Edit file /etc/postfix/main.cf, add to the bottom:

mydomain_fallback = localhost
mail_owner = _postfix
setgid_group = _postdrop
relayhost = smtp.gmail.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
#smtp_tls_security_level = encrypt
#tls_random_source = dev:/dev/urandom
smtp_sasl_mechanism_filter = login
smtp_sasl_mechanism_filter = login

in sasl_passwd:

smtp.gmail.com:587 username@gmail.com:password

to test set-up:

date | mail -s test test@testdomain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.