LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-20-2009, 08:37 AM   #1
Geert86
Member
 
Registered: Jul 2008
Posts: 46

Rep: Reputation: 15
Sending mail from command line


Dear all,

I am trying to setup a linux server, with debian, and want to make use of the mail() function in php. Therefore I have done the following:
- install sendmail
- change php.ini and set sendmail_path

But I am not able to send any mails. When I look in my error logs, it says (after making a php script that implements mail()):
/var/log/mail.log
DSN: User unknown
DSN: Service unavailable

I am not very into networking, so I don't know where to start looking, or what is wrong. Can somebody help me?

Best regards, Geert
 
Old 11-20-2009, 09:06 AM   #2
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 438

Rep: Reputation: 57
Does basic mailing from the command line work?
For example:
Code:
cat /etc/hosts |mailx yourname@youremail
If that doesn't work, you may want to verify your sendmail config.
 
Old 11-20-2009, 09:36 AM   #3
cybernet2u
LQ Newbie
 
Registered: Aug 2009
Distribution: centos
Posts: 16

Rep: Reputation: 0
Question

Quote:
Originally Posted by MBybee View Post
Does basic mailing from the command line work?
For example:
Code:
cat /etc/hosts |mailx yourname@youremail
If that doesn't work, you may want to verify your sendmail config.
sorry for offtopic
the above comand should send an email to the specified address ?
i change it in a real email address and i didn't received anything
 
Old 11-20-2009, 12:12 PM   #4
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 438

Rep: Reputation: 57
Quote:
Originally Posted by cybernet2u View Post
sorry for offtopic
the above comand should send an email to the specified address ?
i change it in a real email address and i didn't received anything
Yes, it should. Depends on how your system is set up. I use it in quite a few scripts and such on all my servers to send alerts.

On desktops this isn't typically configured, but neither is sendmail.

Here's a config guide:
http://man-wiki.net/index.php/1:mailx
 
Old 11-21-2009, 02:44 PM   #5
cybernet2u
LQ Newbie
 
Registered: Aug 2009
Distribution: centos
Posts: 16

Rep: Reputation: 0
Quote:
Originally Posted by MBybee View Post
Yes, it should. Depends on how your system is set up. I use it in quite a few scripts and such on all my servers to send alerts.

On desktops this isn't typically configured, but neither is sendmail.

Here's a config guide:
http://man-wiki.net/index.php/1:mailx
thanks
 
Old 11-30-2009, 07:39 AM   #6
Geert86
Member
 
Registered: Jul 2008
Posts: 46

Original Poster
Rep: Reputation: 15
Unfortunate basic mailing doesn't work. Telnet does work however, when I specify my smtp server. So what config options do I need to change? I use sendmail.
 
Old 11-30-2009, 09:14 AM   #7
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 438

Rep: Reputation: 57
Quote:
Originally Posted by Geert86 View Post
Unfortunate basic mailing doesn't work. Telnet does work however, when I specify my smtp server. So what config options do I need to change? I use sendmail.
Where were the steps in the sendmail config doc where you had problems?
 
Old 11-30-2009, 09:17 AM   #8
Geert86
Member
 
Registered: Jul 2008
Posts: 46

Original Poster
Rep: Reputation: 15
I couldn't find where to say through which smtp server to send my mail.
 
Old 11-30-2009, 09:46 AM   #9
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 438

Rep: Reputation: 57
Quote:
Originally Posted by Geert86 View Post
I couldn't find where to say through which smtp server to send my mail.
You mean to forward it within your domain, or outside?

If you're doing outbound MTA only (don't deliver mail from 'the internet' to your network, just collect mail locally and send it to another host) try this:
http://www.cyberciti.biz/faq/linux-c...ubmission-mta/

Otherwise, try this:
http://www.wikihow.com/Configure-Sendmail

That one is pretty straightforward. Basically the sendmail.cf holds most of the settings for sendmail.
 
Old 11-30-2009, 09:58 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by cybernet2u View Post
sorry for offtopic
the above comand should send an email to the specified address ?
i change it in a real email address and i didn't received anything
Try a simpler test to see if very basic sendmail is working
Code:
cat /etc/hosts | mailx root
 
Old 11-30-2009, 12:04 PM   #11
Geert86
Member
 
Registered: Jul 2008
Posts: 46

Original Poster
Rep: Reputation: 15
OK, we are coming somewhere. When I dot his, I get the following error (sultan.arnhem.chello.nl is no 'real' domain off course):

mail -v test@gburg.nl

Can't send mail: sendmail process failed with error code 69

sultan:/home/geert# mail -v test@gburg.nl
Subject: testen 777
dit is een test
.
Cc:
test@gburg.nl... Connecting to mail.upcmail.nl. via relay...
220 edge02.upc.biz edge ESMTP server ready
>>> EHLO sultan.arnhem.chello.nl
250-edge02.upc.biz hello [62.194.232.122], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 15360000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
>>> MAIL From:<root@sultan.arnhem.chello.nl> SIZE=55 AUTH=root@sultan.arnhem.chello.nl
550 5.1.0 <root@sultan.arnhem.chello.nl> sender rejected
root... Using cached ESMTP connection to mail.upcmail.nl. via relay...
>>> RSET
250 2.0.0 OK
>>> MAIL From:<> SIZE=1079
250 2.1.0 <> sender ok
>>> RCPT To:<root@sultan.arnhem.chello.nl>
550 5.1.1 <sultan.arnhem.chello.nl> invalid domain
>>> DATA
503 5.5.0 need RCPT before DATA
>>> RSET
250 2.0.0 OK
>>> RSET
250 2.0.0 OK
postmaster... Using cached ESMTP connection to mail.upcmail.nl. via relay...
>>> MAIL From:<> SIZE=2103
250 2.1.0 <> sender ok
>>> RCPT To:<postmaster@sultan.arnhem.chello.nl>
550 5.1.1 <sultan.arnhem.chello.nl> invalid domain
>>> DATA
503 5.5.0 need RCPT before DATA
>>> RSET
250 2.0.0 OK
MAILER-DAEMON... Saved message in /var/lib/sendmail/dead.letter
Closing connection to mail.upcmail.nl.
>>> QUIT
221 2.0.0 edge02.upc.biz edge closing connection
Can't send mail: sendmail process failed with error code 69
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Sendmail (mailserver) -- sending mail with the mail command -- doesn't work :-( carolinevdh Linux - Server 1 08-13-2009 09:43 PM
Debian etch - Unable to send mail from command line or from php mail command lqforumuser Linux - Newbie 1 03-01-2009 06:56 AM
Sending mail from Comman line ddzc Linux - Software 1 01-23-2007 10:23 AM
Sending mail from command line matiasquestions Linux - Software 5 01-22-2006 11:51 AM
sending mail from command line won't work disorderly Linux - General 2 06-09-2005 11:29 AM


All times are GMT -5. The time now is 07:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration