Find out which mail server is installed on Ubuntu - email

I have access to a couple of Ubuntu servers and I am trying to configure the PHP mail() command for each of these servers. However, for one of these servers, the From: header is overwritten by www-data#. I have no access to the SPF record of that hostname, so I want to configure the mail server so it doesn't overwrite the From: header.
So my question is, how do I find out which mail server is used so I can correctly configure that mail server? (Postfix, SSMTP, ...)
Thanks in advance!

To get a list of packages installed locally do this in your terminal:
dpkg --get-selections | grep -v deinstall
To save that list to a text file called packages on your desktop do this in your terminal:
dpkg --get-selections | grep -v deinstall > ~/Desktop/packages
Then search for Mailserver. I'll do my bet for Postfix, which seems to be the most used.
Credit goes here

$ dpkg -l | grep mail
rc libc-client2007e 8:2007f~dfsg-4 amd64 c-client library for mail protocols - library files
ii libmail-sendmail-perl 0.79.16-1 all Send email from a perl script
ii libmailtools-perl 2.13-1 all Manipulate email in perl programs
ii libmailutils4:amd64 1:2.99.99-1ubuntu2 amd64 GNU Mail abstraction library
ii mailutils 1:2.99.99-1ubuntu2 amd64 GNU mailutils utilities for handling mail
ii mailutils-common 1:2.99.99-1ubuntu2 all Common files for GNU mailutils
ii mime-support 3.59ubuntu1 all MIME files 'mime.types' & 'mailcap', and support programs
ii postfix 3.1.0-3ubuntu0.3 amd64 High-performance mail transport agent

Finding which server is listening on port 25 may help (expecially if you have multiple MTA installed but only one which one is running).
(sudo) netstat -tanp | grep ':25'
As Following suggested, you need to be root (sudo).
You will get the PID of the process, for example :
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 98249/master
Here I found the PID (98249 in my case), and you can get more information with ps or lsof
ps 98249
lsof -p 98249

Related

How do I use "ST-link GDB server"

I installed the ST-Link GDB server from the ST webpage (link)
ST created "ST-Link Server" (link) which bridges the architecture gap and enables us to comfortably monitor and debug the "running binary" (arm architecture) on our workstation PC (x86 or x86_64 architercture) using the "GDB" debugger.
To install the "ST-Link Server" I first download it's .zip file that I can get on the bottom of the page that i linked in the previous paragraph:
Then I uncompress it and run the .msi file that can be found in the compressed file structure. Note that installation wizard will install a command line tool stlinkserver.exe inside the folder:
/mnt/c/Program\ Files\ \(x86\)/STMicroelectronics/stlink_server/
So I move inside and prompt for help:
ziga#EN3310278:~$ cd /mnt/c/Program\ Files\ \(x86\)/STMicroelectronics/stlink_server/
ziga#EN3310278:stlink_server$ ./stlinkserver.exe --help
stlink-server
--help | -h display this help
--version | -v display STLinkserver version
--port | -p set tcp listening port
--debug | -d set debug level <0-5> (incremental, 0: Error, 1:Info, 2:Warning, 3:STlink, 4:Debug, 5:Usb)
--auto-exit | -a exit() when there is no more client
--log_output | -l redirect log output to file <name>
There are very little parameters listed! Weird... Also useless... This seemed weird to me so I investigated further.
"ST-Link Server" has a nice documentation "UM2576" (link). But in the documentation there are more parameters listed than stlinkserver.exe returns to us.
At this point I was so confused that I tried executing one parameter i.e. -g listed in the "UM2576" and application really failed to recognize the parameter:
ziga#EN3310278:stlink_server$ ./stlinkserver.exe -g
stlinkserver.exe: unknown option -- g
Info : default port : 7184
Info : 127.0.0.1:7184
Info : ctrl_handler 0
Ctrl-C event
What is going on with ST? Why doesn't the "ST-Link GDB server" work? How do you use it? I am really confused... And most importantly... I can not connect to my board?
Should I just throw in the towel and use J-Link or OpenOCD???
ST-link server and ST-link GDB server are two different pieces of software.
ST-link server is a tool for sharing a debug adaptor between multiple programs, for example an IDE debugger and command-line programmer. It owns the USB connection and other programs connect to it over sockets.
ST-link GDB server is the server portion of the GNU debugger, configured to use an ST-link adaptor.
If you read the documentation for one and install the other I would expect the arguments not to match up!

orangehrm test email not send

I have installed OrangeHrm 3.3.3 on Ubuntu 14.04 Server and now trying to configure SMTP Email.
The credentials and settings are correct. I am using same in SuiteCRM installed on CentOS 7.
The message I get
Settings Saved. Test email not sent.
I remember doing this on CentOS:
chcon -R -t httpd_sys_content_rw_t /var/www/html
setsebool httpd_can_network_connect=on
setsebool httpd_can_sendmail=on
setsebool httpd_unified=on
Is there some similar settings for Apache on Ubuntu where I can allow sendmail on the server?
I would highly appreciate your input.
Thanks in advance.
/AAN

installing MailHog on Linux virtual box to capture outgoing emails

I wanted to ease the development by installing MailHog on my centos linux development environment in my virtual box. The php mail() function doesn't report any issues (that is, it returns TRUE) but the outgoing mails did not appear in MailHog. How should I set it up correctly?
Follow these steps:
Download the appropriate MailHog version from https://github.com/mailhog/MailHog/releases. I use MailHog_linux_amd64 in this example but you may need a different version. I assume you use your home directory to store your files. In the likely case you don't do this, please, make the required modifications accordingly.
If your VM uses ip filtering then you should allow the communication through port 8025 with adding a line to the iptable config and restarting it:
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8025 -j ACCEPT
service iptables restart
Launch MailHog with the following command:
./MailHog_linux_amd64 -hostname=mylocal.vbox:8025
where mylocal.vbox is the domain name how the host sees the VM. Now you should see some lines detailing which IP addresses and ports it uses.
Download mhsendmail from here: https://github.com/mailhog/mhsendmail/releases.
Change it to be executable (adjust the path of the file accordingly):
chmod 777 /home/you/mhsendmail_linux_amd641
Change your php.ini to use mhsendmail instead of sendmail:
vim /etc/php.ini
sendmail_path = "/home/you/mhsendmail_linux_amd64"
service httpd restart
View the MailHog web interface from your host computer (use the host name we used above): http://mylocal.vbox:8025/. The webmail interface of MailHog should appear.
Test mail sending from the command line of the VM with this oneliner:
php -r "\$from = \$to = 'your.emailaddress#gmail.com'; \$x = mail(\$to, 'subject'.time(), 'Hello World', 'From: '. \$from); var_dump(\$x);"
It should display true and the web interface of the MailHog should display the new email.
Have fun, send as many emails via the mail() function of php as you want.
Some more ideas:
If you want to override the default IP address and port settings then you should use the following syntax:
./MailHog_linux_amd64 -ui-bind-addr=192.168.56.104:8026 -api-bind-addr=192.168.56.104:8026 -hostname=mylocal.vbox:8026 -smtp-bind-addr=192.168.56.104:8025
In this case you will have to escape the settings in php.ini this way:
sendmail_path = "/home/you/mhsendmail_linux_amd64 --smtp-addr=""192.168.56.104:8025"""

How to use Tor Network on a non-gui server with perl

I want to write a perl-script that loads content from internet-websites through the TOR network. The script should run on a non-gui ubuntu server (Ubuntu 12.04).
Just to make it clear: I want to install no TOR server and no TOR browser. I want to install a TOR client that makes it possible for other programs like perl scripts to access web content through the TOR network.
My questions:
Where do I find a TOR client for a non-gui ubuntu-machine?
How to install this client?
Must I install anything else (maybe some additional cpan modules)?
Do you have a short example perl script that loads a website through the TOR network?
sudo apt-get install tor - then you can either use proxychains <your command> OR usewithtor <your command> OR torify <your command>

What is a faster alternative to Python's http.server (or SimpleHTTPServer)?

Python's http.server (or SimpleHTTPServer for Python 2) is a great way of serve the contents of the current directory from the command line:
python -m http.server
However, as far as web servers go, it's very slooooow...
It behaves as though it's single threaded, and occasionally causes timeout errors when loading JavaScript AMD modules using RequireJS. It can take five to ten seconds to load a simple page with no images.
What's a faster alternative that is just as convenient?
http-server for node.js is very convenient, and is a lot faster than Python's SimpleHTTPServer. This is primarily because it uses asynchronous IO for concurrent handling of requests, instead of serialising requests.
Installation
Install node.js if you haven't already. Then use the node package manager (npm) to install the package, using the -g option to install globally. If you're on Windows you'll need a prompt with administrator permissions, and on Linux/OSX you'll want to sudo the command:
npm install http-server -g
This will download any required dependencies and install http-server.
Use
Now, from any directory, you can type:
http-server [path] [options]
Path is optional, defaulting to ./public if it exists, otherwise ./.
Options are [defaults]:
-p The port number to listen on [8080]
-a The host address to bind to [localhost]
-i Display directory index pages [True]
-s or --silent Silent mode won't log to the console
-h or --help Displays help message and exits
So to serve the current directory on port 8000, type:
http-server -p 8000
I recommend: Twisted (http://twistedmatrix.com)
an event-driven networking engine written in Python and licensed under the open source MIT license.
It's cross-platform and was preinstalled on OS X 10.5 to 10.12. Amongst other things you can start up a simple web server in the current directory with:
twistd -no web --path=.
Details
Explanation of Options (see twistd --help for more):
-n, --nodaemon don't daemonize, don't use default umask of 0077
-o, --no_save do not save state on shutdown
"web" is a Command that runs a simple web server on top of the Twisted async engine. It also accepts command line options (after the "web" command - see twistd web --help for more):
--path= <path> is either a specific file or a directory to be
set as the root of the web server. Use this if you
have a directory full of HTML, cgi, php3, epy, or rpy
files or any other files that you want to be served up
raw.
There are also a bunch of other commands such as:
conch A Conch SSH service.
dns A domain name server.
ftp An FTP server.
inetd An inetd(8) replacement.
mail An email service
... etc
Installation
Ubuntu
sudo apt-get install python-twisted-web (or python-twisted for the full engine)
Mac OS-X (comes preinstalled on 10.5 - 10.12, or is available in MacPorts and through Pip)
sudo port install py-twisted
Windows
installer available for download at http://twistedmatrix.com/
HTTPS
Twisted can also utilise security certificates to encrypt the connection. Use this with your existing --path and --port (for plain HTTP) options.
twistd -no web -c cert.pem -k privkey.pem --https=4433
go 1.0 includes a http server & util for serving files with a few lines of code.
package main
import (
"fmt"; "log"; "net/http"
)
func main() {
fmt.Println("Serving files in the current directory on port 8080")
http.Handle("/", http.FileServer(http.Dir(".")))
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
Run this source using go run myserver.go or to build an executable go build myserver.go
Try webfs, it's tiny and doesn't depend on having a platform like node.js or python installed.
If you use Mercurial, you can use the built in HTTP server. In the folder you wish to serve up:
hg serve
From the docs:
export the repository via HTTP
Start a local HTTP repository browser and pull server.
By default, the server logs accesses to stdout and errors to
stderr. Use the "-A" and "-E" options to log to files.
options:
-A --accesslog name of access log file to write to
-d --daemon run server in background
--daemon-pipefds used internally by daemon mode
-E --errorlog name of error log file to write to
-p --port port to listen on (default: 8000)
-a --address address to listen on (default: all interfaces)
--prefix prefix path to serve from (default: server root)
-n --name name to show in web pages (default: working dir)
--webdir-conf name of the webdir config file (serve more than one repo)
--pid-file name of file to write process ID to
--stdio for remote clients
-t --templates web templates to use
--style template style to use
-6 --ipv6 use IPv6 in addition to IPv4
--certificate SSL certificate file
use "hg -v help serve" to show global options
Here's another. It's a Chrome Extension
Once installed you can run it by creating a new tab in Chrome and clicking the apps button near the top left
It has a simple gui. Click choose folder, then click the http://127.0.0.1:8887 link
https://www.youtube.com/watch?v=AK6swHiPtew
I found python -m http.server unreliableā€”some responses would take seconds.
Now I use a server called Ran https://github.com/m3ng9i/ran
Ran: a simple static web server written in Go
Also consider devd a small webserver written in go. Binaries for many platforms are available here.
devd -ol path/to/files/to/serve
It's small, fast, and provides some interesting optional features like live-reloading when your files change.
If you have PHP installed you could use the builtin server.
php -S 0:8080
give polpetta a try ...
npm install -g polpetta
then you can
polpetta ~/folder
and you are ready to go :-)
Using Servez as a server
Download Servez
Install It, Run it
Choose the folder to serve
Pick "Start"
Go to http://localhost:8080 or pick "Launch Browser"
Note: I threw this together because Web Server for Chrome is going away since Chrome is removing support for apps and because I support art students who have zero experience with the command line
Yet another node based simple command line server
https://github.com/greggman/servez-cli
Written partly in response to http-server having issues, particularly on windows.
installation
Install node.js then
npm install -g servez
usage
servez [options] [path]
With no path it serves the current folder.
By default it serves index.html for folder paths if it exists. It serves a directory listing for folders otherwise. It also serves CORS headers. You can optionally turn on basic authentication with --username=somename --password=somepass and you can serve https.
I like live-server. It is fast and has a nice live reload feature, which is very convenient during developpement.
Usage is very simple:
cd ~/Sites/
live-server
By default it creates a server with IP 127.0.0.1 and port 8080.
http://127.0.0.1:8080/
If port 8080 is not free, it uses another port:
http://127.0.0.1:52749/
http://127.0.0.1:52858/
If you need to see the web server on other machines in your local network, you can check what is your IP and use:
live-server --host=192.168.1.121
And here is a script that automatically grab the IP address of the default interface. It works on macOS only.
If you put it in .bash_profile, the live-server command will automatically launch the server with the correct IP.
# **
# Get IP address of default interface
# *
function getIPofDefaultInterface()
{
local __resultvar=$1
# Get default route interface
if=$(route -n get 0.0.0.0 2>/dev/null | awk '/interface: / {print $2}')
if [ -n "$if" ]; then
# Get IP of the default route interface
local __IP=$( ipconfig getifaddr $if )
eval $__resultvar="'$__IP'"
else
# Echo "No default route found"
eval $__resultvar="'0.0.0.0'"
fi
}
alias getIP='getIPofDefaultInterface IP; echo $IP'
# **
# live-server
# https://www.npmjs.com/package/live-server
# *
alias live-server='getIPofDefaultInterface IP && live-server --host=$IP'
I've been using filebrowser for the past couple of years and it is the best alternative I have found.
Features I love about it:
Cross-platform: It supports Linux, MacOs and Windows (+). It also supports docker (+).
Downloading stuff is a breeze. It can automatically convert a folder into zip, tar.gz and etc. for transferring folders.
You can file or folder access to every use.