Mail

= Sendmail =

Installation sudo apt-get install sendmail

Configuration for using SMTP server sudo nano /etc/mail/sendmail.mc

At the end, add below below 2 line between existing 1st & 4th Line: MAILER(`local')dnl MAILER_DEFINITIONS define('SMART_HOST',`smtp.gmail.com') MAILER(`smtp')dnl

Now reconfigure sendmail to use above config: sudo bash -c 'cd /etc/mail/ && m4 sendmail.mc >sendmail.cf' sudo service sendmail restart

Troubleshooting
If you are unable to send emails, check below log file: sudo cat /var/log/mail.err

If you get this error: My unqualified host name (test-ubuntu) unknown; sleeping for retrytest-ubuntu

Edit hosts file to add below entries sudo nano /etc/hosts 127.0.0.1      localhost.localdomain test-ubuntu

Authentication
Make auth subdirectory in mail config directory: cd /etc/mail mkdir auth chmod 700 auth

Create a file with your auth information to the smtp server cd auth touch client-info

In the file, put the following, matching up to your smtp server: AuthInfo:mail.domain.com "U:root" "I:username" "P:password"

Generate the Authentication database, make both files readable only by root makemap hash client-info < client-info chmod 600 client-info cd ..

Add the following lines to sendmail.mc. Make sure you update your smtp server MAILER_DEFINITIONS

FEATURE(`authinfo',`hash /etc/mail/auth/client-info.db')dnl MAILER(`local')dnl MAILER_DEFINITIONS define(`SMART_HOST',`mail.domain.com')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl MAILER(`smtp')dnl

Invoke creation sendmail.cf sudo sendmailconfig

Test Mail: sendmail -t myaddress@gmail.com -v -i < body.txt

Testing
Connect to the server telnet 127.0.0.1 25
 * Manual Testing using Telnet

If you see similar to below lines, you are connected to the server: 220 test-ubuntu ESMTP Sendmail 8.15.2/8.15.2/Debian-3; Wed, 2 Aug 2017 13:45:29 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]

Issue below commands/Inputs one by one to send a test mail: HELO server

MAIL from:amanjosan2008@gmail.com

RCPT to: amandeep.singh@citrix.com

DATA Subject:Test mail hello amandeep.singh@citrix.com from amanjosan2008@gmail.com This is the body .

If you see this output, your mail is queued to be send: 250 2.0.0 v7289CNJ007111 Message accepted for delivery

Exit the program: quit

Create a sample body file nano body.txt Paste below text into it: Subject: test mail to Some Address! From: Me  To: Vasya first line of my message
 * Testing using CLI

Send email using below command: /usr/sbin/sendmail -t -f myaddress@gmail.com -v -i < body.txt

PHP Mail
COnfigure PH to use Sendmail: /etc/php5/apache2/php.ini:

Add at the end of this file: ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "/usr/sbin/sendmail -t -f myaddress@gmail.com -i"

Restart Apache server: sudo service apache2 restart


 * PHP Script to send mail

Create a PHP file in the root Directory: sudo nano /var/www/html/mail.php

Paste and save the below contents in it: 

Your mail should be sent after you open below link in browser: http://10.107.88.68/mail.php

= SendEmail =

http://caspian.dotconf.net/menu/Software/SendEmail/

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

cd sendEmail-v1.56/ mv sendEmail /usr/local/bin/ cp -a sendEmail /usr/local/bin/ sudo cp -a sendEmail /usr/local/bin/ sendEmail

sendEmail -f codered@citrix.com -t amandeep.singh@citrix.com -s mail.citrix.com -u "Codered Test Mail" -o message-file=/home/test/body3.txt -o message-content-type=html -a ~/logo.png

= Mutt =

Source: linux.com github.io

= SSMTP = Source: askubuntu.com

=Misc =

Figure out SMTP address
Open CMD.exe and type below commands: nslookup set type=MX domain.name
 * Windows:

dig domain.name MX
 * Linux:


 * References