postfix smtp relaying questions.

Discussion in 'HOWTO-Related Questions' started by kameleon25, Feb 9, 2008.

  1. kameleon25

    kameleon25 New Member

    I setup postfix on my ISPConfig server to use SMTP relaying using this link: http://www.howtoforge.com/postfix_relaying_through_another_mailserver . It worked like a charm.... EXCEPT: When I reply to an email I sent from the server it goes to the gmail account I am relaying through (as in I send myself a test message to another email address). Is there a way I can get around this? Rather than have the recipient change the email address it is going back to?

    Basically I am trying to find a way that I can send mails from my server (which is on a static IP with Comcrap) and it function just as a regular e-mail sever. Is there any other way to do this?
     
    Last edited: Feb 9, 2008
  2. falko

    falko Super Moderator Howtoforge Staff

  3. kameleon25

    kameleon25 New Member

    It is not a "static" but i have had the same IP since i had the service... Well over a year now. So I call it static. It is blacklisted because it comes from "a dynamic pool of ip's from a residential broadband provider". As in I cannot email my blackberry, my wife at her state job, or alot of others. Hence the need for the relaying. I also have a dreamhost hosting account for my company and tried relaying through it but that did not work either.
     
  4. kameleon25

    kameleon25 New Member

    On a side note, I do have access to a linux machine on a static IP that is not on any blacklists. But all I could do on it is possibly setup postfix to allow authenticated relaying. Would that do what I need also? I just can't run the full ISPConfig server on that machine. I do apologize, I am just now getting to where I am having to mess with mail servers this deep. I appreciate any and all help.
     
  5. falko

    falko Super Moderator Howtoforge Staff

    I'm not sure why this is happening. What's in /etc/postfix/main.cf?
     
  6. kameleon25

    kameleon25 New Member

    Here is my main.cf. Thanks for the help!
    Code:
    cat /etc/postfix/main.cf
    # See /usr/share/postfix/main.cf.dist for a commented, more complete version
    
    
    # Debian specific:  Specifying a file name will cause the first
    # line of that file to be used as the name.  The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname
    
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    biff = no
    
    # appending .domain is the MUA's job.
    append_dot_mydomain = no
    
    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h
    
    readme_directory = no
    
    # TLS parameters
    smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
    smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
    smtpd_use_tls = yes
    smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
    
    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.
    
    myhostname = machine.domain.tld
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    #mydestination = machine.domain.tld, localhost.domain.tld, , localhost
    relayhost = smtp.gmail.com:587
    mynetworks = 127.0.0.0/8
    mailbox_command = procmail -a "$EXTENSION"
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all
    smtpd_sasl_local_domain = 
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_security_options = noanonymous
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
    smtpd_tls_auth_only = no
    smtp_use_tls = yes
    smtp_tls_note_starttls_offer = yes
    smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes
    smtpd_tls_session_cache_timeout = 3600s
    tls_random_source = dev:/dev/urandom
    
    virtual_maps = hash:/etc/postfix/virtusertable
    
    mydestination = /etc/postfix/local-host-names
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = 
     
  7. falko

    falko Super Moderator Howtoforge Staff

    Is the domain you're sending to listed in /etc/postfix/local-host-names?
     
  8. kameleon25

    kameleon25 New Member

    No it isn't. I have tried sending to my work email, my wife's work, gmail, yahoo, and a few other domains. All of them get the emails now that i can relay through gmail but the FROM address is re-written to be the gmail address I am relaying through.

    I think at this point I have 3 options.
    1. Pay for the actual static IP from my ISP ($250 setup fee plus more per month for less speed than I have now... it's comcraptic!)
    2. Pay for the DynDNS outbound mail hop relaying. ($15 a year for up to 150 messages a day)
    3. Setup something on this other machine I have access to that will allow authenticated smtp relay that will just pass off the message to whoever I am sending it to without modifying the FROM or whatever.

    I don't like #1 because it costs too much at the moment. #2 is ok but I don't learn anything in the process. I would opt for #3 if I could but everywhere I look online for a guide to do that it seems non-existent. Unless I am just blind or not searching for the right stuff. I know it is possible to setup Postfix (or whatever) to allow authenticated SMTP relaying and it should be possible to do so with it just passing the message on to the destination without modifying it any. I figure the reason gmail does that is because anyone can relay through them like that to send spam. Any pointers on a good walkthrough on doing what I want?
     
  9. falko

    falko Super Moderator Howtoforge Staff

    That's the problem. If you're using ISPConfig, please create a web site and an email account for that domain.
     
  10. kameleon25

    kameleon25 New Member

    I may not have made my situation clear. Let me take a step back and explain it from the beginning.

    I have an ubuntu 7.10 server running ISPConfig with 2 domains on it at the moment. Both are fully functional and can receive mail. Although when I send mail TO certain domains FROM any of the email address's on the server (either domain) I get blocked because I am sending mail "from an IP that is part of a dynamic pool of IP's assigned to a residential broadband internet provider". Basically my IP is blacklisted. And without having to spend more money I don't have on getting switched to a "business" setup w/ static ip I decided to try to relay through gmail. I sucsefully setup postfix to relay through gmail. I am now able to send mail TO anyone FROM any email address at any domain on my server. The only problem now is that when I send an email from any address hosted on my server it is relayed through gmail and gmail rewrites my FROM: address to be that of the gmail account I am relaying through. This is not ideal as my customers would all be showing up as sending "from" the gmail address. I read that gmail does this to prevent spam.

    So now I am looking at setting up a dedicated mail relay machine. I have access to a machine on a static IP that is not on any blacklist. I guess what I need to know and cannot seem to find through my searches online is how to setup postfix (or anything similar) to where I can set it as my "relayhost=" in my main.cf on my ISPConfig box and it not rewrite the FROM: address on every outgoing mail message. Unless I am totally missing something. Is there a way to setup postfix to allow mail "relay" from only one host (my ISPConfig server)?

    I hope that clears up what I am wanting to do. Sorry for the confusion.
     
  11. falko

    falko Super Moderator Howtoforge Staff

    Add your ISPConfig IP address to mynetworks on the relay server, e.g. like this:
    Code:
    mynetworks = 127.0.0.0/8 1.2.3.4/32
    Then restart Postfix.
     
  12. kameleon25

    kameleon25 New Member

    You totally rock. I setup postfix on the offsite server per the postfix section of the "perfect server" for ubuntu 7.10 and added that line to the main.cf... works like a charm. Thank you very much!
     

Share This Page