LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-25-2021, 11:12 AM   #1
dba_not_adm9
LQ Newbie
 
Registered: Jan 2021
Posts: 4

Rep: Reputation: Disabled
Send mail smtp config


Hello-

I'm not a sysdamin and if this was already documented somewhere I apologize.

Requirement: Send email as part of shell script with log file as attachment.

My code: echo "Export of database completed at `date`" | mail -s "Subject Here" <email_address> -a logfile.log


The above code runs without any errors but I do not receive the email.

Question: Where do I tell mail command what my smtp relay server for email ? The man page did have options other than creating account and I am not sure if that is the best approach.
 
Old 01-25-2021, 04:18 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
The mail command will use the local mail transport by default. This means the mail gets processed by procmail, which in turn will forward it to the local Mail Transport Agent (MTA) for all non-local recipients.

By default, most MTAs will attempt to deliver external mail directly via SMTP to whatever server the domain in question is using. This will most likely not work in your scenario, since your server is not a registered mail server for any domain. Also, many (if not most) ISPs will insist on you using their relay server for all outgoing mail in order to prevent abuse (spam).

If outgoing SMTP is blocked, your mail will be stuck in the local queue (run mailq to check). If not, the mail was probably rejected or summarily deleted by anti-spam measures at the receiving end.

Depending on the capabilities of the mail command on your system, you may be able to tell it to use an external SMTP server instead of the local transport.

Another (and IMHO better) option would be to configure the local MTA to use whatever SMTP relay your ISP has made available to you. This may or may not require authentication, depending on your ISP.

Your MTA is most likely Postfix or sendmail ("man sendmail" will tell you).
 
Old 01-31-2021, 11:33 AM   #3
dba_not_adm9
LQ Newbie
 
Registered: Jan 2021
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for your response.

The server I am trying to send the email is NOT yet joined to the domain and not sure if that would ever join the domain.

Is there a way to modify procmail or mailq ? Or is there a easier utility to use to accomplish what I am trying to do ?
 
Old 01-31-2021, 11:43 AM   #4
dba_not_adm9
LQ Newbie
 
Registered: Jan 2021
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ser Olmy View Post

Another (and IMHO better) option would be to configure the local MTA to use whatever SMTP relay your ISP has made available to you. This may or may not require authentication, depending on your ISP.

Your MTA is most likely Postfix or sendmail ("man sendmail" will tell you).


I will look into this and reply to the thread.
 
  


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
Postfix keeps creating mail in queue to send to sender's mail address after SMTP integration unclesamcrazy Linux - Newbie 3 07-19-2019 04:50 AM
SMTP newbie queries: #< #5.3.5 SMTP; 553 5.3.5 system config error> #SMTP# LYC Linux - Newbie 0 12-04-2014 12:45 AM
Want to send mail with php mail() command - minimum config required? FeathersMc Linux - Server 2 10-26-2008 12:21 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 10:40 PM
Unable to send mail to some mail servers due smtp greetings malformed atotomex Linux - Networking 6 12-20-2005 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:34 AM.

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