LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-24-2013, 08:50 PM   #1
scout_game
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Rep: Reputation: Disabled
how to route postfix to use a proxy ?


Hello, suppose i have a socks 5 proxy address 82.159.36.14:3128. So what i want to do is that when i send a normal email from localdomain:25, postfix forward it the email to the proxy that complete the task. if i simply use for e.g:

proxychains telnet localdomain 25
... write my email

that won't work for my case!

I use ubuntu 12.04 with postfix. I also have searched a lot but i didn't manage to understand some tutorials.

Regards
 
Old 02-25-2013, 02:10 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
This is easy if I understand you right. All you want to do is have postfix accept the mail on the local server but then relay that mail to a "smart host" for actual mail delivery right?

http://www.dnsexit.com/support/mailrelay/postfix.html is a guide on how to set it up for a specific relay server. Just replace the server values in the guide with your own.
 
1 members found this post helpful.
Old 02-25-2013, 09:40 PM   #3
scout_game
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi, thank you for your answer but this is not what i am pleaning to do I want to route the email through a proxy server so that the originating ip of email header looks the one of the proxy and not the one of my dsl connection.
 
Old 02-26-2013, 11:26 AM   #4
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
That is what you want, search the term "postfix relay host" or "email smart host" to get some more info. Postfix isn't going to actually deliver the mail but you need an MTA(Mail Transfer Agent) in order to get the email to where it needs to go, in this case the proxy server. It will just hand off all of the email generated on the local system to the proxy server where it will actually be delivered from. The IP of the proxy server will be the message headers.
 
1 members found this post helpful.
Old 02-26-2013, 06:21 PM   #5
scout_game
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you, I have downloaded emailrelay software : emailrelay.sourceforge.net

Now how do I tell it to forward messages to tor on 127.0.0.1:9050 ? postfix is using from 127.0.0.1:25.
I tried the command :

Code:
sudo emailrelay --as-proxy=127.0.0.1:9050
But i get those errors :

Code:
emailrelay: error: cannot bind the listening port: 0.0.0.0:25                                                                                                                                   
emailrelay: exception: cannot bind the listening port: 0.0.0.0:25
 
Old 02-26-2013, 06:25 PM   #6
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Dude! Are you even reading my posts?

All you have to do is set the relayhost directive in the postfix config file and it will relay your email. POSTFIX WILL NOT ACTUALLY DELIVER THE EMAIL! Remove the emailrelay binary and follow the steps I gave.


Edit your /etc/postfix/main.cf and find the line that has:

Code:
#relayhost = blahblah
Remove the # so it is not commented out and change the value, in this case "blahblah", to your email relay servers IP.


If this doesnt make sense ask some clarification questions, you are making this way harder on yourself.
 
1 members found this post helpful.
Old 02-26-2013, 10:11 PM   #7
scout_game
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you again, i have found a working solution for free bsd, but i need to translate it to work for ubuntu :
Step 1:
in master.cf
Code:
    smtp      unix  -       -       n       -       -       smtp
    relay     unix  -       -       n       -       -       smtp_socks
Step 2:
Code:
    cat > /usr/libexec/postfix/smtp_socks <<EOF
    #!/bin/sh

    export LD_PRELOAD=/usr/local/lib/libsocks5_sh.so
    export SOCKS_SERVER=127.0.0.1:9050 

    exec /usr/libexec/postfix/smtp $@

    EOF
chmod 755 /usr/libexec/postfix/smtp_socks

I managed to replace that library with an alternative witch is tsocks, so /usr/local/lib/libsocks5_sh.so will become /usr/lib/libtsocks.so. But I don't know how to proceed for the rest! I don't understand how to deal with /usr/libexec/postfix because i don't have such directory.

Here is the original text : http://www.groovy.net/ww/2011/12/torfix.txt

regards
 
Old 02-27-2013, 12:37 PM   #8
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Do you have the file /etc/postfix/main.cf? You dont need to mess with any of the libraries. Have you found the "relayhost" directive in the main.cf and changed it yet? That is all you have to do, then restart postfix and test it. The only other things that could be an issue would be smtp auth settings which I can tell you which directives to change based upon any error you get.


Just stick with what I have told you, nothing more.

Find the /etc/postfix/main.cf file, edit it and find the relayhost line. Change the directive to point to your servers IP such as:

Code:
relayhost = [serverip]
 
Old 02-27-2013, 07:07 PM   #9
scout_game
LQ Newbie
 
Registered: Oct 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hello, I have tested so many cases, but no mgs's received.

relayhost = [127.0.0.1:9050]
relayhost = [127.0.0.1]
relayhost = 127.0.0.1:9050
relayhost = 127.0.0.1 9050

even tried :
relayhost = smtp.live.com
relayhost = [smtp.live.com]

doesn't work also.

I doubt it will work for whatever any smtp server i give, not any server is relaying and i don't want to pay for paid one because i only need to send a couple of mails regulary about 75 messages to recipients per week. So the best i want to achieve is to use tor network and 127.0.0.1 with port 9050 so the message header ip will contain tor exit node ip and not my own to bypass geo ip filters.
My local server needs to send messages to users so i wouldn't like to miss someone. If you can clarify for me how to configure postfix with tor than you are welcome.
regards
 
Old 02-27-2013, 08:21 PM   #10
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
So let me clarify what you want here:

You don't want relay mail to another server for delivery. You want emails to be delivered from your server but show as if they were delivered from another server? Is that correct?


If thats the case its spam and I will not help someone do that. You should have no problem relaying mail through your ISP, if they refuse to let you relay based upon the content or the number of emails you will have to pay for a service like the rest of the legitimate emailers out there.

Last edited by Kustom42; 02-27-2013 at 08:22 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Proxy that route on file-suffix and domain? HeloMe Linux - Networking 4 01-24-2013 05:57 AM
Route a proxy from a VPN into the Internet an0r0c Linux - Networking 0 04-04-2009 11:47 AM
squid! not able to route clients through proxy haxpak Linux - Server 2 01-07-2009 07:42 AM
postfix - No route to host - errors levand Linux - Networking 5 11-19-2004 10:28 PM
route from proxy server to internel servers mchitrakar Linux - Networking 2 11-10-2004 05:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration