LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How much should I know to send simple email (https://www.linuxquestions.org/questions/linux-newbie-8/how-much-should-i-know-to-send-simple-email-743485/)

iwonder 07-28-2009 02:43 PM

How much should I know to send simple email
 
I am using CentOS 5.3 to learn linux.

Objective: I am writing a script that when my IP is changed, an email will be sent to inform me the new IP.
So, sending a short text thru internet by a command line is all I need.

I have do some reading that cover MUA MTA MDA, warnings about open relay, using of m4 and makemap, ... and I still have no idea where to find the answer I need, not even close.
I'm not setting mail server, and I intend not receiving email.

Please suggest me some areas/keywords to focus. Many thanks for your help.

acid_kewpie 07-28-2009 02:53 PM

you don't need to know anything about mail really. just run "echo this is a message | mail dave@dave.com" and off it should go. If you're doing any more than bash, the php, perl, ruby etc... have their own mail() routines.

iwonder 07-28-2009 11:25 PM

I tried but failed.
I was thinking about 2 issues, and not sure if anything else is missed.
The 1st thing is about the default tight setup on "relay" by CentOS. The 2nd is from my experience in setup Outlook Express that I should input something like smpt.my_isp.com, and maybe corresponding id and password as well.

For what I have tried, I received an error message from email. Unfortunately, I am too green to decode it.

Then, I add one more line to the file /etc/mail/access
Connect:192.168.1.1 RELAY
and run the following line
makemap hash access.db < access
This time, when I tried echo "message" | mail myname@myisp.com , I still receive no email, while error message (internal email) changed from 550 & 503 to 501 Data format error.

The error message:
Quote:

From MAILER-DAEMON@host.home Wed Jul 29 02:44:14 2009
Date: Wed, 29 Jul 2009 02:44:14 +0800
From: Mail Delivery Subsystem <MAILER-DAEMON@host.home>
To: <root@host.home>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="n6SIiELw005038.1248806654/host.home"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)

This is a MIME-encapsulated message

--n6SIiELw005038.1248806654/host.home

The original message was received at Wed, 29 Jul 2009 02:44:01 +0800
from host.home [127.0.0.1]

----- The following addresses had permanent fatal errors -----
<myname@myisp.com>
(reason: 553 5.1.8 <myname@myisp.com>... Domain of sender address root@host.home does not exist)

----- Transcript of session follows -----
... while talking to imsmx1.myisp.com.:
>>> DATA
<<< 553 5.1.8 <myname@myisp.com>... Domain of sender address root@host.home does not exist
550 5.1.1 <myname@myisp.com>... User unknown
<<< 503 5.0.0 Need RCPT (recipient)

--n6SIiELw005038.1248806654/host.home
Content-Type: message/delivery-status

Reporting-MTA: dns; host.home
Received-From-MTA: DNS; host.home
Arrival-Date: Wed, 29 Jul 2009 02:44:01 +0800

Final-Recipient: RFC822; myname@myisp.com
Action: failed

Quote:



chrism01 07-29-2009 01:56 AM

You do know there's a free service that does this http://www.dyndns.com/services/dns/dyndns/ or are you keen to learn for academic reasons?

iwonder 07-29-2009 02:25 AM

Quote:

Originally Posted by chrism01 (Post 3623848)
You do know there's a free service that does this http://www.dyndns.com/services/dns/dyndns/ or are you keen to learn for academic reasons?

Well, in fact, this kind of service will be blocked from time to time somewhere on the planet.
I want to learn more so that I can have more alternatives when need.

iwonder 07-29-2009 11:13 PM

I have edited the sendmail.mc file, input the smtp server of my isp so that the following line is there.
define(`SMART_HOST', `smtp.myisp.com')dnl
I run make -C /etc/mail to make the above line effective.
I tried echo "message" | mail myname@myisp.com , and get the same error 553 domain does not exist.

I then tried Evolution in gui.
The setup is as simple as Outlook Express. I only input the smtp server name, with no user authentication.
Email sent and received (on another PC thru internet) instantly.
This step confirms me that the smtp server of my isp do not need authentication.
But Evolution is still not my answer cause command line can only create an email at OutBox. User must press the send button to send the email.

I start to wonder if this kind of "trouble" is made intentionally in linux world in order to discourage spam mail?
I do find some names of other smtp clients but query if this is the right direction to go (if I am intentionally discouraged to do so)?

centos82 07-29-2009 11:41 PM

You're on the right track with "define(`SMART_HOST', `smtp.myisp.com')dnl"

The problem looks like your ISP mail server doesn't recognize who it's getting mail from.

If you have a domain name try adding:
dnl MASQUERADE_DOMAIN(mydomain.com)dnl

or at the very least put your ISP's domain there.

iwonder 07-30-2009 01:41 AM

Quote:

Originally Posted by centos82 (Post 3625003)
You're on the right track with "define(`SMART_HOST', `smtp.myisp.com')dnl"

The problem looks like your ISP mail server doesn't recognize who it's getting mail from.

If you have a domain name try adding:
dnl MASQUERADE_DOMAIN(mydomain.com)dnl

or at the very least put your ISP's domain there.

Thank you for your reply.
I have tried host.home/home/myisp.com in the MASQUERADE_DOMAIN line but with no luck.

I have not set up DNS so I think I don't have the needed domain name here. Am I correct? Must I set up a DNS server, or I can merely "declare" it somewhere?

The latest error message is
Quote:

----- The following addresses had permanent fatal errors -----
<myname@myisp.com>
(reason: 553 host.home does not exist)

----- Transcript of session follows -----
... while talking to smtp.myisp.com.:
>>> MAIL From:<root@host.home> SIZE=525
<<< 553 host.home does not exist
501 5.6.0 Data format error

catkin 07-30-2009 02:16 AM

Hello iwonder :)

In postfix, I had to:
  • Assign a real domain name to my computer (myhostname = mydomainname.co.uk)
  • Configure my mail service provider's smtp server name (relayhost = [smtp.mymailserviceprovider.com])
  • Configure the username and password I use to log on to my mail service provider's smtp server (smtp_sasl_password_maps = hash:/etc/postfix/password)
I understand you are using sendmail, not postfix, but you probably need to configure equivalents in sendmail.

If you don't have a real domain name to use you could ask your mail service provider what their requirements are; for security, most check that the domain name is valid. Mine does not check that the sending IP is associated with the domain name. That does suggest that you can use any valid domain name but it would be very rude to use one without permission!

Best

Charles

colucix 07-30-2009 02:26 AM

Quote:

Originally Posted by iwonder (Post 3623757)
<<< 553 5.1.8 <myname@myisp.com>... Domain of sender address root@host.home does not exist

Once I had the same problem using sendmail. I solved by the -f option:
Code:

echo message | /usr/sbin/sendmail -f root@host.home myname@myisp.com

iwonder 07-30-2009 03:42 AM

Quote:

Originally Posted by catkin (Post 3625118)
Hello iwonder :)
...

If you don't have a real domain name to use you could ask your mail service provider what their requirements are; for security, most check that the domain name is valid. Mine does not check that the sending IP is associated with the domain name. That does suggest that you can use any valid domain name but it would be very rude to use one without permission!
Best
Charles

Thanks Charles for your reply. I tends to believe the job shouldn't be that tedious cause I can can use Evolution to do it in a very simple way. Unless, Evolution do "some part" of dns server job at the background. I don't know, but I guess not.

iwonder 07-30-2009 03:53 AM

Quote:

Originally Posted by colucix (Post 3625133)
Once I had the same problem using sendmail. I solved by the -f option:
Code:

echo message | /usr/sbin/sendmail -f root@host.home myname@myisp.com

Great. Million Thanks.
I change it a little bit to
Code:

echo message | /uer/sbin/sendmail -f myname@myisp.com myname@hotmail.com
and it works !!!

A note for other readers is to beware that the 1st email will be grouped under "JUNK" by Hotmail. Don't miss it.


All times are GMT -5. The time now is 05:45 AM.