Script to configure Gmail as relayhost in postfix

Discussion in 'General' started by ramoncio, Oct 16, 2009.

  1. ramoncio

    Joined:
    May 12, 2010
    Messages:
    1,663
    Likes Received:
    0
    With this script you can configure Gmail using sasl auth as relayhost for postfix, to deliver all your emails.
    If you run it as it is, it starts asking the user for the gmail credentials and some data needed to customize the SSL certificate, but it can also be easily made fully unattended, assigning values to the variables and removing the first lines (starting with read).

    Code:
    wget http://www.lolacolay.com/ramon/postfixgmail.sh
    chmod +x postfixgmail.sh
    ./postfixgmail.sh
    
     
  2. Acidizer

    Joined:
    Mar 11, 2010
    Messages:
    6
    Likes Received:
    0
    That was peace of cace to set up even for complete NOB like i am, thanks a lot :)
     
  3. rollinsolo

    Joined:
    Feb 11, 2009
    Messages:
    279
    Likes Received:
    0
    +1 to you for that, will this work for different types of email accounts that require authentication, I am thinking once I set up a user and new password I can modify the script to create the certs for their email host instead, it is not gmail.
     
  4. bhallottawa

    Joined:
    Jun 6, 2010
    Messages:
    14
    Likes Received:
    0
    This worked Awesome!

    Thanks
    Bob
     
  5. rollinsolo

    Joined:
    Feb 11, 2009
    Messages:
    279
    Likes Received:
    0
    Ramoncio the only thing I would change in the script is who sends the email in vm_general.inc in /etc/asterisk, if you change serveremail, who the email appears to come from which would be the email used to authenticate mail this script works for any email server out there, well gmail and an exchange server hosted in the Amazon Cloud, the only other file I had to change was /etc/postfix/generic and take out anything before the first @ sign so the line looks similar to @pbx.local username@gmail.com
    then do a postmap /etc/postfix/generic and restart postfix or reboot server and email will go through authenticating to just about anyone.
    Thanks for this could not have done it for a customer of mine without this.
     
  6. rollinsolo

    Joined:
    Feb 11, 2009
    Messages:
    279
    Likes Received:
    0
    I also see you lost your Karma somehow well heres one more for this.
     
  7. ramoncio

    Joined:
    May 12, 2010
    Messages:
    1,663
    Likes Received:
    0
    Thanks for that!!

    Someone took my karma away, I see...
    I'll have to start over :(
     
  8. rollinsolo

    Joined:
    Feb 11, 2009
    Messages:
    279
    Likes Received:
    0
    If they can fix it I think you were at least 60+ I left you one for the script and then noticed your were at 0 again, kinda sucks FIX IT GUYS he earned each and every one of those. Side note Ramoncio do you know how to make UUCP send mail as root my voicemail to email goes thru authenticated using your script but faxes are being sent from=<uucp@pbx.local> as opposed to from=<asterisk@pbx.local> and are being rejected because the sender does not have permission to send as this sender, I am trying to tread lightly because its a customer production server, also hard to replicate on my own because they use their own mail client and mine is working both ways using Gmail. Thanks.
     
  9. rnrover

    Joined:
    Aug 2, 2009
    Messages:
    73
    Likes Received:
    0
    Fantastic Script. I spent half a day trying to get email working before I found your script. It took 5 minutes once I got your script.

    Thanks again :woohoo:
     
  10. mambo

    Joined:
    Aug 2, 2011
    Messages:
    11
    Likes Received:
    0
    Re: Re:Script to configure Gmail as relayhost in postfix

    Excelent ... very good script..thk.
     
  11. benboone

    Joined:
    Sep 1, 2012
    Messages:
    6
    Likes Received:
    0
    I have setup postfix before but this was by far the easiest setup for gmail relay that I have ever done. thanks!!
     
  12. oscarbello84

    Joined:
    Jun 4, 2010
    Messages:
    2
    Likes Received:
    0
    Hello, I'm trying to run the script in a CentOS-6.3 server and I get this error:

    Starting postfix: [ OK ]
    Generating DSA parameters, 1024 bit long prime
    This could take some time
    .......+.....+..+................+++++++++++++++++++++++++++++++++++++++++++++++++++*
    .....+...........+.+...+...+.........+.....+..+...+.........+.+.......+......+....................+.................+..............+...................+.......+.............................................+.+.+.....+.....+...........+...+.......+..............+.....+....+.........+....+...........+.+..........+.......+...........+...+.............+.+.+.+........+.....+..+..+........+.+....+.......+.....+..+.....+.......+......+.......................+..................+++++++++++++++++++++++++++++++++++++++++++++++++++*
    Generating a 1024 bit DSA private key
    writing new private key to 'mykey.pem'
    -----
    140229566310216:error:0606B06E:digital envelope routines:EVP_SignFinal:wrong public key type:p_sign.c:142:
    140229566310216:error:0D0C3006:asn1 encoding routines:ASN1_item_sign:EVP lib:a_sign.c:279:
    140237058017096:error:0606B06E:digital envelope routines:EVP_SignFinal:wrong public key type:p_sign.c:142:
    140237058017096:error:0D0C3006:asn1 encoding routines:ASN1_item_sign:EVP lib:a_sign.c:279:

    Cual puede ser la causa?
     
  13. rehan22

    Joined:
    Nov 8, 2012
    Messages:
    1
    Likes Received:
    0
    where is the script?

    Regards,
    Rehan
     
  14. benboone

    Joined:
    Sep 1, 2012
    Messages:
    6
    Likes Received:
    0
  15. jgutierrez

    Joined:
    Feb 28, 2008
    Messages:
    5,737
    Likes Received:
    0
    Now you can do it from the web interface, go to Email module, Remote SMTP and select gmail.
     
  16. apmuthu

    Joined:
    Aug 1, 2009
    Messages:
    60
    Likes Received:
    0
    Can someone repost this script as the link is not working now.
     
  17. Damian_Carter

    Joined:
    Aug 10, 2013
    Messages:
    43
    Likes Received:
    0
    I see the newest version has gmail accounts built in. However it doesn't work as indicated by the elastix bible :)

    can I use this utility to repair the issue? I do not see a specific instruction on how to implement this script. Also I will try this on a non production box before implementing this. Again thanks in advance for your help
     
  18. Amphibian

    Joined:
    Sep 8, 2009
    Messages:
    1,128
    Likes Received:
    2
    Damian_Carter,

    Gmail does work in version 2.04 if you go to "remote smtp" and set it up there. The only issue I had in the beginning was the right port number (587 or 25). Once that was corrected all worked fine to this day.


    amphibian
     

Share This Page