Score:0

how to send test email with sendmail

cn flag

I've setup the FQDN in /etc/hosts:

127.0.0.1 hostname.domain hostname
127.0.0.1 localhost
  • however if I run hostname it returns the FQDN?? is something wrong here?

Then ran: sendmailconfig

I've used this to test: echo "Subject: hello" | sendmail -v [email protected] < mail.txt But i can't sucessfully send... It hangs like this:

root@debianxx:~# echo "Subject: hello" | sendmail -v [email protected] < email.txt 
[email protected]... Connecting to [127.0.0.1] via relay...
220 debianxx.online ESMTP Sendmail 8.15.2/8.15.2/Debian-22; Sat, 19 Nov 2022 07:53:11 GMT; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO debianxx.online
250-debianxx.online Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<[email protected]> SIZE=47 [email protected]
250 2.1.0 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .

it hangs at the '.' prompt no matter what I type.

  • ps: I've already checked for the open port with nc -l 25.

Edit sendmail log:

Nov 19 12:21:14 simplysocial sendmail[7718]: alias database /etc/mail/aliases rebuilt by root
Nov 19 12:21:14 simplysocial sendmail[7718]: /etc/mail/aliases: 0 aliases, longest 0 bytes, 0 bytes total
Nov 19 12:21:14 simplysocial sm-mta[7784]: starting daemon (8.15.2): SMTP+queueing@00:10:00
Nov 19 12:21:29 simplysocial sendmail[8460]: alias database /etc/mail/aliases rebuilt by root
Nov 19 12:21:29 simplysocial sendmail[8460]: /etc/mail/aliases: 0 aliases, longest 0 bytes, 0 bytes total
Nov 19 12:21:31 simplysocial sm-mta[7784]: restarting /usr/sbin/sendmail-mta due to signal
Nov 19 12:21:31 simplysocial sm-mta[8510]: starting daemon (8.15.2): SMTP+queueing@00:10:00
Nov 19 12:21:52 simplysocial sendmail[8544]: 2AJCLq0k008544: from=root, size=47, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Nov 19 12:21:52 simplysocial sm-mta[8545]: 2AJCLqu9008545: from=<[email protected]>, size=335, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Nov 19 12:21:52 simplysocial sendmail[8544]: 2AJCLq0k008544: [email protected], ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30047, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (2AJCLqu9008545 Message accepted for delivery)

Anton A avatar
cn flag
I ran traceroute: ```traceroute -n -T -p 25 gmail-smtp-in.l.google.com traceroute to gmail-smtp-in.l.google.com (173.194.76.26), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * 4 * * * 5 * * * 6 * * * 7 * * * 8 * * * 9 * * * 10 * * * 11 * * * 12 * * * 13 * * * 14 * * * 15 * * * 16 * * * 17 * * * 18 * * * 19 * * * 20 * * * 21 * * * 22 * * * 23 * * * 24 * * * 25 * * * 26 * * * 27 * * * 28 * * * 29 * * * 30 * * *``` what does this imply?
Score:0
la flag

I've setup the FQDN in /etc/hosts but I run hostname it returns the FQDN? Is something wrong here?

No.

  1. The notion your system has for its hostname is independent of what is, or is not, set in /etc/hosts.
    Your systems hostname is a kernel tunable (see for example sysctl kernel.hostname or cat /proc/sys/kernel/hostname) that is normally set boot time in a distribution specific way (on systemd based hosts you typically configure the system hostname with hostnamectl) and the hostname can be changed at runtime with the hostname some.name command or similar commands such as sysctl kernel.hostname=some.name or hostnamectl set-hostname some.name etc.
    Depending on the method that change is persistent or the the hostname will revert at the next reboot.

  2. Although there are conventions there is nowadays generally no actual (technical) requirement for the hostname some.name to be either a short single label hostname or a FQDN hostname.example.com.. Both are allowed : see for example Setting the hostname: FQDN or short name?

  3. When you set a FQDN as the hostname both the hostname command and the hostname --fqdn command will return a FQDN.


It should be noted that the sendmail command is not intended as a user interface routine and there are much better utilities to send mail from the command line. The classic mail command and mailx for example.

Is sendmail logging an error message in your system logs?

The output Connecting to [127.0.0.1] via relay. suggests that you have configured sendmail with a relay, a "smart host" in sendmail jargon.

Can that relay be reached?

Anton A avatar
cn flag
i've tried postfix and now i get " Connection timed out" error. as per my traceroute; isnt the port 25 being blocked; maybe the nc connection made it thorough ipv6? according to searching around here...
Anton A avatar
cn flag
i dont have the sendmail logs but it said something ' message accepted' but never actually delevered
Anton A avatar
cn flag
i've attached the sendmail logs
diya avatar
la flag
`Message accepted for delivery` suggests that something went right. Are there more lines? Check the `mailq` command and/or your mailbox contents (common defaults are /var/spool/mail )
Anton A avatar
cn flag
MSP Queue status... /var/spool/mqueue-client is empty Total requests: 0 MTA Queue status... /var/spool/mqueue (23 requests) -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- 2AJCLqu9008545* 17 Sat Nov 19 12:21 <[email protected]> <[email protected]>
Anton A avatar
cn flag
there are other connection timed out but those are from postfix attempts. is there a way to avoid the relay mode? thank you for your attention
diya avatar
la flag
connection time outs suggest that a remote smtp port, TCP 25 can't be reached. Many consumer ISP as well as hosting providers block outgoing SMTP to port 25 to prevent SPAM and you either need to use their relay service or third part that will let you send mail via their mail service
Anton A avatar
cn flag
i wonder how the nc command connected?? i raise a request with the vps provider and see
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.