LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 07-24-2009, 12:53 PM   #1
andrei_b
LQ Newbie
 
Registered: Jul 2009
Posts: 11

Rep: Reputation: 0
using function mail() in PHP, ..sendmail configuration problem..? - Ubuntu 9.04


Hello!
I'm trying to send an email to my yahoo adress, using function mail(), as follows:

Quote:
<?php
$to = "my_adress@yahoo.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
if (@mail($to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
}
else {
echo('<p>Mail could not be sent.</p>');
}
?>
I'm using XAMPP (/opt/lampp).
I've installed sendmail from Synaptic Package Manager (I'm using Ubuntu 9.04).
The message shown in the web page is "Mail sent successfully." (after almost one minute of not displaying anything), but there is no new mail in my yahoo mailbox. I don't know how to configure sendmail and /opt/lampp/etc/php.ini properly.

When I try to send mail via Terminal (command line), again, it takes a lot of time (almost one minute) and the message is not send. I've got the following errors in the log files from /var/log/mail.err:
Code:
Jul 24 17:31:23 andrei-laptop sendmail[1646]: My unqualified host name (andrei-laptop) unknown; sleeping for retry
Jul 24 17:32:23 andrei-laptop sendmail[1646]: unable to qualify my own domain name (andrei-laptop) -- using short name
Jul 24 17:32:23 andrei-laptop sm-mta[1740]: My unqualified host name (andrei-laptop) unknown; sleeping for retry
Jul 24 17:32:25 andrei-laptop sm-msp-queue[1745]: My unqualified host name (andrei-laptop) unknown; sleeping for retry
Jul 24 17:33:23 andrei-laptop sm-mta[1740]: unable to qualify my own domain name (andrei-laptop) -- using short name
Jul 24 17:33:45 andrei-laptop sm-msp-queue[1745]: unable to qualify my own domain name (andrei-laptop) -- using short name
or in /var/log/mail.log
Code:
Jul 24 17:48:19 andrei-laptop sendmail[3128]: My unqualified host name (andrei-laptop) unknown; sleeping for retry
Jul 24 17:48:36 andrei-laptop sendmail[3101]: unable to qualify my own domain name (andrei-laptop) -- using short name
Jul 24 17:48:36 andrei-laptop sendmail[3101]: n6OEma83003101: from=andrei, size=87, class=0, nrcpts=1, msgid=<200907241448.n6OEma83003101@andrei-laptop>, relay=andrei@localhost
Jul 24 17:48:37 andrei-laptop sm-mta[3142]: n6OEmaNe003142: from=<andrei@andrei-laptop>, size=344, class=0, nrcpts=1, msgid=<200907241448.n6OEma83003101@andrei-laptop>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Jul 24 17:48:37 andrei-laptop sendmail[3101]: n6OEma83003101: to=my_adress@yahoo.com, ctladdr=andrei (1000/1000), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30087, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (n6OEmaNe003142 Message accepted for delivery)
Jul 24 17:48:42 andrei-laptop sm-mta[3144]: n6OEmaNe003142: to=<my_adress@yahoo.com>, ctladdr=<andrei@andrei-laptop> (1000/1000), delay=00:00:05, xdelay=00:00:05, mailer=esmtp, pri=120344, relay=e.mx.mail.yahoo.com. [216.39.53.1], dsn=5.0.0, stat=Service unavailable
Jul 24 17:48:42 andrei-laptop sm-mta[3144]: n6OEmaNe003142: n6OEmgNe003144: DSN: Service unavailable
Jul 24 17:48:42 andrei-laptop sm-mta[3144]: n6OEmgNe003144: to=<andrei@andrei-laptop>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent
Sorry for adding so much text here...
Now, the most important, here is a section of my /opt/lampp/etc/php.ini file.. which way should I change it?
Code:
[mail function]
; For Win32 only.
SMTP = localhost
;smtp_port = 25 ?should this be uncommented?--------------------

; For Win32 only.
sendmail_from = my_adress@yahoo.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/lib/sm.bin/sendmail -t
By the way, there is sendmail, in /usr/lib/sm.bin/sendmail.

I also have the httpd.conf file in /opt/lampp/etc, which is quite important in server's configuration.
so, a part of httpd.conf:
Code:
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
# XAMPP
ServerName localhost

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/andrei/Public"
I hope someone could help. Any advice is welcome.
Thank you very much!

Last edited by andrei_b; 07-24-2009 at 12:54 PM.
 
Old 07-25-2009, 09:54 PM   #2
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Maybe you should try to add to your /etc/hosts file:
Code:
xx.xx.xx.xx andrei-laptop andrei
Your IP goes in the place of the xx's
I wouldn't change php.ini for now and in httpd.conf you can add your email.

Last edited by micxz; 07-25-2009 at 09:56 PM. Reason: php.ini
 
Old 07-25-2009, 09:59 PM   #3
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
I think this line:
Code:
if (@mail($to, $subject, $message)) {
should be:
Code:
if (mail($to, $subject, $message)) {
 
Old 09-02-2010, 05:50 AM   #4
duleorlovic
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
sendmail configuration problem

I have the same problem.
Sep 2 09:22:15 orlovic-desktop sendmail[5151]: My unqualified host name (orlovic-desktop) unknown; sleeping for retry
I have checked that outbound port 25 is open with command "telnet mt-example.com 25", so I think that problem is in sendmail configuration.
Does anybody know the solution from the hand?
 
Old 09-02-2010, 10:26 AM   #5
duleorlovic
LQ Newbie
 
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
I resolve my problem in two steps.
First I add domain name in /etc/hosts, for example>
Quote:
127.0.1.1 orlovic-desktop mydomen.com
Then put
Quote:
localhost
in /etc/allow because of the firewall.
 
1 members found this post helpful.
Old 09-02-2010, 10:12 PM   #6
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Glad you fixed it but this thread is over a year old!
 
  


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
PHP Mail() Problem w/ Sendmail jusme Linux - Software 6 08-18-2012 02:35 PM
PHP mail() function and sendmail: stat=Service unavailable xpucto Linux - Server 1 03-22-2007 10:25 AM
sendmail and PHP mail() function tudekoen Debian 1 05-09-2004 03:53 AM
sendmail and PHP mail() function tudekoen Linux - Software 0 05-08-2004 04:45 PM
PHP - mail function saravanan1979 Programming 2 08-06-2003 01:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:12 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