ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Basically, I want to create a script which send an email if any of the condition is not met. So, it's like an alarm. So now, my problem is how to open an email to send a message from a script. Could anybody give me an idea...
I have tried the following commands but to no avail. There was no error when I run the script, but I didn't receive any email. Is there anything I need to setup beforehand? Thanks for your prompt reply...
You need to give more information. What error messages are you getting (if at all), when you try that? Both of those commands should work, if everything is set up properly.
You need sendmail working to use those. Are you sure you have sendmail installed and working? rpm -q sendmail will tell you if it's installed. It will give you the name and version number, or if it's not installed, it'll say package sendmail is not installed.
If it's not installed, install it by doing (as root), yum install sendmail, then follow the following steps once it's installed.
If it's installed, you have to check that it's actually started up. As root, type service sendmail status.
I think it should say Checking for service sendmail: [OK], if it's working properly. If it's not running, you can start it with service sendmail start, and to ensure it starts when you boot up next time, then type chkconfig sendmail on.
If it's installed, and running properly, then the problem could very well be your ISP. Some ISP's block outgoing mail if it's not send through their SMTP server (SBC, for example, does that).
You'd use "mailx" under Solaris, "mail" under Linux. The redirections ("cat hello.txt | command" and "command < hello.txt") are in their effect equivalent. You don't absolutely need the sendmail *package*; e.g., qmail provides a perfect replacement (and claims to be secure).
It's quite possible that your MTA isn't configured correctly. If so, the 'mail' program could run without errors, but the message could still fail to send and you'd see errors in a logfile somewhere in /var/log/*
Unfortunately I don't even know what mta fedora uses by default, let alone how to tweak it.
You need to give more information. What error messages are you getting (if at all), when you try that? Both of those commands should work, if everything is set up properly.
You need sendmail working to use those. Are you sure you have sendmail installed and working? rpm -q sendmail will tell you if it's installed. It will give you the name and version number, or if it's not installed, it'll say package sendmail is not installed.
If it's not installed, install it by doing (as root), yum install sendmail, then follow the following steps once it's installed.
If it's installed, you have to check that it's actually started up. As root, type service sendmail status.
I think it should say Checking for service sendmail: [OK], if it's working properly. If it's not running, you can start it with service sendmail start, and to ensure it starts when you boot up next time, then type chkconfig sendmail on.
If it's installed, and running properly, then the problem could very well be your ISP. Some ISP's block outgoing mail if it's not send through their SMTP server (SBC, for example, does that).
Hi drj,
This is what I got I executed the commands checking for the status of the sendmail. It seems it is installed and running. Is there any work around on how to unblock outgoing mail if it's not send through the SMTP server? Do I need to set up my email using my ISP pop server...Thanks for your prompt reply...
[root@john ~]# rpm -q sendmail
sendmail-8.13.5-3
[root@john ~]# service sendmail status
sendmail (pid 2938 2305 2301 2296) is running...
It's quite possible that your MTA isn't configured correctly. If so, the 'mail' program could run without errors, but the message could still fail to send and you'd see errors in a logfile somewhere in /var/log/*
Unfortunately I don't even know what mta fedora uses by default, let alone how to tweak it.
Hi aluser,
The following is what I got ferom the maillog.Can you see anything wrong with the log? How could I configure my MTA. Could you give me an idea...Sori m pretty much novice with Linux system... Thanks for your prompt reply...
Aug 28 20:42:52 john sendmail[2935]: k7T0gqLA002935: to=johnsanty@yahoo.com, ctladdr=johnsanty (500/500), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30054, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (k7T0gq6H002936 Message accepted for delivery)
You need to give more information. What error messages are you getting (if at all), when you try that? Both of those commands should work, if everything is set up properly.
You need sendmail working to use those. Are you sure you have sendmail installed and working? rpm -q sendmail will tell you if it's installed. It will give you the name and version number, or if it's not installed, it'll say package sendmail is not installed.
If it's not installed, install it by doing (as root), yum install sendmail, then follow the following steps once it's installed.
If it's installed, you have to check that it's actually started up. As root, type service sendmail status.
I think it should say Checking for service sendmail: [OK], if it's working properly. If it's not running, you can start it with service sendmail start, and to ensure it starts when you boot up next time, then type chkconfig sendmail on.
If it's installed, and running properly, then the problem could very well be your ISP. Some ISP's block outgoing mail if it's not send through their SMTP server (SBC, for example, does that).
Hi All,
I'm not sure if this is related. I tried to set up my Evolution email using my ISP pop and smtp servers then i got an error message when I tried to send an email to my yahoo account. The error message is the following:
"Error while performing operation.
MAIL FROM command failed: Must issue a STARTTLS command first"
Now, i tried to search for this error and one person suggested that I need to enable the TLS..how could I enable my TLS...? Thanks for your help....
John,
It seems the question shifted to whether you can send e-mail at all, whether from a script or outside? You could try mailing directly from the shell, i.e.,
Code:
echo The message body | mail -s "A subject" johnsanty@yahoo.com
And probably you get the same as from the script. (And when you add the -v option to mail it will just tell you your computer (127.0.0.1) accepted it for delivery -- while we are interested in seeing the session going out to the net.)
Requiring STARTTLS probably means someone insist on encryption. Not sure who, maybe your ISP? It's not your e-mail provider yahoo, as the session below shows. You can manually run SMTP sessions, and it can help figuring out what the problem is. So starting with the e-mail address you provided above, I did the following. What I typed is bold.
Code:
% host -t mx yahoo.com
yahoo.com mail is handled by 1 mx1.mail.yahoo.com.
yahoo.com mail is handled by 1 mx2.mail.yahoo.com.
yahoo.com mail is handled by 1 mx3.mail.yahoo.com.
yahoo.com mail is handled by 5 mx4.mail.yahoo.com.
% telnet mx1.mail.yahoo.com 25
Trying 4.79.181.14...
Connected to mx1.mail.yahoo.com.
Escape character is '^]'.
220 mta183.mail.mud.yahoo.com ESMTP YSmtp service ready
HELO lithum.mydomain.com
250 mta183.mail.mud.yahoo.com
MAIL From: <brechbuehler@gmail.com>
250 sender <brechbuehler@gmail.com> ok
RCPT To: <johnsanty@yahoo.com>
250 recipient <johnsanty@yahoo.com> ok
RSET
250 reset ok
QUIT
221 mta183.mail.mud.yahoo.com
You see it got past MAIL From without problem. I issued RSET to avoid sending you unsolicited mail.
Now I don't know what your sendmail does -- maybe it relays all outgoing mail through your ISP who insists on encryption? Or it talks directly to the destination MTA (e.g., mx1.mail.yahoo.com)? Try to pinpoint the problem. If it's your sendmail configuration, there should be a number of people on this forum who can help you.
From the log message the OP posted, it looks like sendmail may be trying to send directly to the destination mail server (I'm guessing this because it says it's using 127.0.0.1 as a relay). If that's the case (I'm not really sure that it is), the destination could be rejecting the mail as spam because it comes from a suspicious dynamic address, or your isp could be filtering outbound connections to port 25.
If you can figure out how to get sendmail to forward everything to your isp's smtp server that might help. in the debian configs that is called a "smarthost"
Can you try to telnet to mx1.mail.yahoo.com, port 25? If you get to the 220 message, at least you know your ISP isn't filtering those connections.
Also, you could look in the mail log (where you found "relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (k7T0gq6H002936 Message accepted for delivery)") and see if you can locate further down an entry when sendmail actually attempts that delivery? It might be informative.
John,
It seems the question shifted to whether you can send e-mail at all, whether from a script or outside? You could try mailing directly from the shell, i.e.,
Code:
echo The message body | mail -s "A subject" johnsanty@yahoo.com
And probably you get the same as from the script. (And when you add the -v option to mail it will just tell you your computer (127.0.0.1) accepted it for delivery -- while we are interested in seeing the session going out to the net.)
Requiring STARTTLS probably means someone insist on encryption. Not sure who, maybe your ISP? It's not your e-mail provider yahoo, as the session below shows. You can manually run SMTP sessions, and it can help figuring out what the problem is. So starting with the e-mail address you provided above, I did the following. What I typed is bold.
Code:
% host -t mx yahoo.com
yahoo.com mail is handled by 1 mx1.mail.yahoo.com.
yahoo.com mail is handled by 1 mx2.mail.yahoo.com.
yahoo.com mail is handled by 1 mx3.mail.yahoo.com.
yahoo.com mail is handled by 5 mx4.mail.yahoo.com.
% telnet mx1.mail.yahoo.com 25
Trying 4.79.181.14...
Connected to mx1.mail.yahoo.com.
Escape character is '^]'.
220 mta183.mail.mud.yahoo.com ESMTP YSmtp service ready
HELO lithum.mydomain.com
250 mta183.mail.mud.yahoo.com
MAIL From: <brechbuehler@gmail.com>
250 sender <brechbuehler@gmail.com> ok
RCPT To: <johnsanty@yahoo.com>
250 recipient <johnsanty@yahoo.com> ok
RSET
250 reset ok
QUIT
221 mta183.mail.mud.yahoo.com
You see it got past MAIL From without problem. I issued RSET to avoid sending you unsolicited mail.
Now I don't know what your sendmail does -- maybe it relays all outgoing mail through your ISP who insists on encryption? Or it talks directly to the destination MTA (e.g., mx1.mail.yahoo.com)? Try to pinpoint the problem. If it's your sendmail configuration, there should be a number of people on this forum who can help you.
Hi Quigi,
Actually, I tried to send mail directly from command line but I got the same result. Now I tried the following:
telnet mx1.mail.yahoo.com 25
And I got the following, it seems that it is not connecting at all.
[johnsanty@babe1 ~]$ telnet mx1.mail.yahoo.com 25
Trying 4.79.181.14...
telnet: connect to address 4.79.181.14: Connection timed out
Trying 4.79.181.15...
telnet: connect to address 4.79.181.15: Connection timed out
Trying 67.28.113.71...
telnet: connect to address 67.28.113.71: Connection timed out
Trying 67.28.113.73...
In the maillog, I got the following. I'm not sure if this message conveys that the message has been sent. Can you confirm?:
However,in the /var/spool/mail, I got the following several of them since I have attempted many time to send an email. Does it look like a problem with my configuration or with yahoo? Also, I tried sending an email to my hotmail account and i got the same thing. Do you have any idea.....i dont know if it is my sendmail configuration or not. Do you know by any chance on how to configure the senmail? Thanks for your prompt reply...
**********************************************
** THIS IS A WARNING MESSAGE ONLY **
** YOU DO NOT NEED TO RESEND YOUR MESSAGE **
**********************************************
The original message was received at Mon, 28 Aug 2006 21:27:23 -0400
from localhost.localdomain [127.0.0.1]
----- Transcript of session follows -----
<johnsanty@yahoo.com>... Deferred: Connection timed out with mx4.mail.yahoo.com.
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old
Return-Path: <jonhsanty@babe1>
Received: from babe1 (localhost.localdomain [127.0.0.1])
by babe1 (8.13.5/8.13.5) with ESMTP id k7T1RNvY002973
for <johnsanty@yahoo.com>; Mon, 28 Aug 2006 21:27:23 -0400
Received: (from btamayo@localhost)
by babe1 (8.13.5/8.13.5/Submit) id k7T1RNVv002972
for johnsanty@yahoo.com; Mon, 28 Aug 2006 21:27:23 -0400
Date: Mon, 28 Aug 2006 21:27:23 -0400
From: John Santy <johnsanty@babe1>
Message-Id: <200608290127.k7T1RNVv002972@babe1>
To: johnsanty@yahoo.com
Subject: john
--k7U2BsfC002300.1156905836/babe1--
From MAILER-DAEMON@babe1 Tue Aug 29 22:47:57 2006
Return-Path: <MAILER-DAEMON@babe1>
Received: from localhost (localhost)
by babe1 (8.13.5/8.13.5) id k7U2BsfD002300;
Tue, 29 Aug 2006 22:47:57 -0400
Date: Tue, 29 Aug 2006 22:47:57 -0400
From: Mail Delivery Subsystem <MAILER-DAEMON@babe1>
Message-Id: <200608300247.k7U2BsfD002300@babe1>
To: <johnsanty@babe1>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="k7U2BsfD002300.1156906077/babe1"
Subject: Warning: could not send message for past 4 hours
Auto-Submitted: auto-generated (warning-timeout)
I tried the following:
telnet mx1.mail.yahoo.com 25
And I got the following, it seems that it is not connecting at all.
[johnsanty@babe1 ~]$ telnet mx1.mail.yahoo.com 25
Trying 4.79.181.14...
telnet: connect to address 4.79.181.14: Connection timed out
Trying 4.79.181.15...
telnet: connect to address 4.79.181.15: Connection timed out
Trying 67.28.113.71...
telnet: connect to address 67.28.113.71: Connection timed out
Trying 67.28.113.73...
Yes. Indeed it looks like your ISP is filtering any outbound connection to port 25. They are going out of their way to make your life more difficult!
Quote:
In the maillog, I got the following. I'm not sure if this message conveys that the message has been sent. Can you confirm?:
No. If I read it right, it only confirms that your own machine (localhost AKA babe1 AKA 127.0.0.1) got the message from you, and will later try to deliver it.
Quote:
However,in the /var/spool/mail, I got the following several of them since I have attempted many time to send an email.
Code:
----- Transcript of session follows -----
<johnsanty@yahoo.com>... Deferred: Connection timed out with mx4.mail.yahoo.com.
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old
Yes, this one documents the real problem. In five days you'll get a final failure notice. You see that sendmail is trying to connect to yahoo's mx machine (just as you did manually above), and the connection times out just as it did for you.
Quote:
Does it look like a problem with my configuration or with yahoo? Also, I tried sending an email to my hotmail account and i got the same thing.
It's a problem with your "friendly" ISP, who doesn't let you talk to yahoo, or hotmail, or any SMTP server (except theirs, presumably). No, it's not a problem with yahoo -- I can talk to them just fine.
Quote:
Do you have any idea.....i dont know if it is my sendmail configuration or not. Do you know by any chance on how to configure the senmail?
Your configuration would be ok with a "normal ISP, but you may need to change it to work around the filtering.
I'm not using sendmail, so I'm not the right person to ask about its configuration. Many years ago I heard people say getting it right is close to black magic. But hopefully things got better. And there is documentation out there. A quick Google search turned up http://sendmail.org and you may particularly want to study the section about configuration, http://www.sendmail.org/m4/readme.html .
If after reading you still have questions, you may want to come back. Maybe even post a new question.
Ok, so to fix sendmail to forward through your ISP, here's what you need to do (all as root, of course):
First, you need to open up sendmail's config file (actually it's the master control file, but no reason to nitpick). If I remember correctly, it's /etc/mail/sendmail.mc
Look for a line that says something like "dnl define(`SMART_HOST', `smtp:smtp.yourisp.net')dnl."
If it doesn't say smtp, that's ok. smtp is the default if it's not specified. Change whatever address is in there to your isp's smtp address, and then delete the dnl at the beginning of the line (but not at the end). Be sure not to change any of the quotes, etc. It uses specific types of quotes, and screws up if the wrong kind are used.
Once you've done that, assuming your current directory is /etc/mail, type make. That should generate a new config file for you. If it didn't (you'll know if it says "Nothing to be done for all"), then you have to do it yourself. "m4 sendmail.mc > sendmail.cf" should do it. Then type service sendmail restart, and you should be good to go.
Now this assumes that you're ISP doesn't require you to login to the smtp server, or use a secure connection. I never was able to figure out how to get it working in that case. I just found another smtp server provided by my ISP that didn't require login.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.