top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to send a mail using sendmail utility in Linux?

+3 votes
605 views

How to send a mail using sendmail utility? Example would help?

posted Apr 28, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Sendmail is a most popular smtp server used in most of Linux/Unix distribution. sendmail allows to send email from command line.

Create a file using following content

# vim /tmp/my_email.txt
Subject: <Subject>

<Email Content>

Now send email using following command

# sendmail user@example.com  < /tmp/my_email.txt

I hope it should help....

answer Apr 28, 2014 by Chahat Sharma
+1 vote

Using 'mail' Command we can sent the e-mails. mail command is most popular command to send emails from Linux terminal. Use few of below examples to send email.

# mail -s "Test Email" user@example.com < /dev/null
-s is used for subject

To send email with attachment.
# mail -a /opt/backup.sql -s "Backup File" user@example.com < /dev/null
-a is used for attachments

Also we can add comma separated emails to send email to multiple recipients together.
# mail -s "Test Email" user@example.com,user2@example.com < /dev/null

answer Jun 11, 2014 by Shatark Bajpai
Similar Questions
+1 vote

I'm running Fedora-24(beta)/KDE, and sendmail/email (through KMail) is failing.
When I try to send email I get the warning "Failed to transmit message", and journalctl has the entry
"sendmail.service: PID file /run/sendmail.pid not readable (yet?)
after start: No such file or directory".

I've checked, and sendmail.pid is in place:

$ sudo cat /run/sendmail.pid 
2829 
/usr/sbin/sendmail -bd -q1h 

Googling for the journalctl entry, I see people have been encountering this problem for years. But I haven't seen any solution offered. Several of the comments suggest that it is a systemd problem.

please help?

+2 votes

I am looking for a python library that does mailing directly through "sendmail".

When I look into the docs, I see only an "smtlip" library but nothing that could serve with sendmail or postfix.

+1 vote

I have a CentOS 6.4 installation running Sendmail, and after some serious hair tear stare and compare I'm a bit stumped. When I connect to the server either with telnet or SSL, sendmail is not presenting the AUTH capability after an EHLO. Everything looks like it should be working, but no amount of tweaking is getting the AUTH capability advertised (and it doesn't work if you just try it anyway).

Here's the config bits from sendmail.mc--

 define(`confAUTH_OPTIONS', `A p')dnl
 define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
 TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

Note: Also tried

 define(`confAUTH_OPTIONS', `A')dnl
 define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl
 TRUST_AUTH_MECH(`LOGIN PLAIN')dnl

just to keep things simple.

saslauthd is running, and configured--/etc/sysconfig/saslauthd 

 SOCKETDIR=/var/run/saslauthd
 MECH=pam
 FLAGS=

/etc/sasl2/Sendmail.conf contains--
 pwcheck_method:saslauthd

/etc/pam.d/smtp contains--
 #%PAM-1.0
 auth include password-auth
 account include password-auth

But when I do "openssl s_client -starttls smtp -connect localhost:587" I don't get any AUTH capability--

ehlo localhost
250-pennzoil.gizmopartners.com Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-DELIVERBY
250 HELP
quit

All the certs are built, and if I connect via telnet, the server does advertise STARTTLS. So anyone able to point out the obvious or not so obvious config mistakes?

...