Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 16th February 2011, 02:26
czeslawoo czeslawoo is offline
Junior Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default sendmail - php mail() function

Hi everybody,

I have a problem with sendmail not sending emails while I am using php mail() function.

My setup is a local LAMP server on Ubuntu, I am using it(or better-setting it up at the moment) as my test web server.

What I have noticed is when I login to the server via STH and run:

czeslawoo@sthserver:~$ sendmail realemail@google.com < testmessage

my email is dispatched and i can recaive it in googlemail.

syslog looks like this:


Feb 16 00:50:22 sthserver sendmail[22458]: My unqualified host name (sthserver) unknown; sleeping for retry
Feb 16 00:51:22 sthserver sendmail[22458]: unable to qualify my own domain name (sthserver) -- using short name
Feb 16 00:51:22 sthserver sendmail[22458]: p1G0pMYt022458: from=czeslawoo, size=23, class=0, nrcpts=1, msgid=<201102160051.p1G0pMYt022458@sthserver>, relay=czeslawoo@localhost
Feb 16 00:51:22 sthserver sm-mta[22461]: p1G0pM4J022461: from=<czeslawoo@sthserver>, size=314, class=0, nrcpts=1, msgid=<201102160051.p1G0pMYt022458@sthserver>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Feb 16 00:51:22 sthserver sendmail[22458]: p1G0pMYt022458: to=realemail@googlemail.com, ctladdr=czeslawoo (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30023, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p1G0pM4J022461 Message accepted for delivery)
Feb 16 00:51:23 sthserver sm-mta[22463]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
Feb 16 00:51:23 sthserver sm-mta[22463]: p1G0pM4J022461: to=<realemail@googlemail.com>, ctladdr=<czeslawoo@sthserver> (1000/1000), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120314, relay=gmail-smtp-in.l.google.com. [209.85.229.27], dsn=2.0.0, stat=Sent (OK 1297817379 j2si5312976wbz.33)

but when I am running my php scrip I have something like this:

Feb 16 00:59:59 sthserver sendmail[22475]: unable to qualify my own domain name (sthserver) -- using short name
Feb 16 00:59:59 sthserver sendmail[22475]: p1G0xxxI022475: from=www-data, size=134, class=0, nrcpts=0, msgid=<201102160059.p1G0xxxI022475@sthserver>, relay=www-data@localhost
Feb 16 01:00:01 sthserver sm-msp-queue[22496]: My unqualified host name (sthserver) unknown; sleeping for retry


What Ive noticed is :
nrcpts = 0 - it cant be good:/
user used in a second case is www-data, and that = apache as far as i know.

Is this just a user related problem?? www-data user does not have rights to use sendmail?? How to make this work??

I dont realy understand sendmail and sorry if this is a trivial problem but I spent so much time on setting this server to work lately ... that i need to now how to fix this problem first and then I look at it and learn how ...

sendmail version is 8.14.3

let me know if you will need any more info

tyvm for help

ps:
php script receive data from simple html feedback form and looks like this:
--------------------------------------------------------------
error_reporting(E_ALL);
ini_set('display_errors', '1');

$email_from = $_POST["email"] ;
$message_from = $_POST["message"] ;
$sendto = "realemail@googlemail.com";
$title = "Feedback Form";

$val = mail( $sendto, $title, $message_from, "FROM: $email_from");

if($val) echo "Email sent";
else echo "Email error" ;

-------------------------------------------------------------------
Reply With Quote
Sponsored Links
  #2  
Old 16th February 2011, 16:42
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

What are the outputs of
Code:
hostname
and
Code:
hostname -f
? My guess is that your server doesn't have a fully-qualified domain name.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 20th February 2011, 23:11
czeslawoo czeslawoo is offline
Junior Member
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

no it doesn't have a fully-qualified domain name, its still in a "test mode".
I will have it connected some-time next week and i will test it again with FQDN.

I just assume that if i can send email using CLI command, i should be able to do a same thing using a php script. Regardless of having FQDN in both cases???
Reply With Quote
  #4  
Old 21st February 2011, 15:01
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

I think Google has a problem with your emails if it can't resolve your hostname. Also, if you're sending from a dynamiv IP, you're most likely blacklisted: http://mxtoolbox.com/blacklists.aspx

Maybe you should set up relaying: http://www.howtoforge.com/postfix_re...her_mailserver
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 11th April 2011, 15:27
vaio vaio is offline
Member
 
Join Date: Nov 2010
Posts: 48
Thanks: 21
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by falko View Post
What are the outputs of
Code:
hostname
and
Code:
hostname -f
? My guess is that your server doesn't have a fully-qualified domain name.
INSTRUCTIONS
# Check we have Fully Qualified Domain Name

/bin/hostname

# it should return something like "ispconfig.example.com"
# if not, then we assign a hostname (for example ispconfig):

echo ispconfig.example.com > /etc/hostname
/etc/init.d/hostname.sh

vi /etc/hosts

# and add lines similar but appropriate:

127.0.0.1 localhost.localdomain localhost
192.168.0.100 ispconfig.example.com ispconfig

Last edited by vaio; 11th April 2011 at 15:40. Reason: instructions paste
Reply With Quote
  #6  
Old 11th April 2011, 15:44
vaio vaio is offline
Member
 
Join Date: Nov 2010
Posts: 48
Thanks: 21
Thanked 1 Time in 1 Post
Default

Falko, what about if you get this error with returned mail:

Quote:
Helo command rejected: need fully-qualified hostname (in
reply to RCPT TO command)
?

if i check hostname it shows ok...
Thank you in advance!
Reply With Quote
  #7  
Old 12th April 2011, 13:30
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
 
Default

Can you check if you use an FQDN in the myorigin directive in /etc/postfix/main.cf?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
libWand.so.10 error Taxick Installation/Configuration 8 3rd May 2009 01:27
localhost postfix/master: fatal: bind 127.0.0.1 port 125: Permission denied g18c Installation/Configuration 4 24th March 2009 17:39
just the last step...and it works. Postfix...need help config. ubuntusr Installation/Configuration 1 5th January 2009 09:50
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18
Postfix reject connections gabrix Server Operation 27 25th January 2007 08:37


All times are GMT +2. The time now is 04:15.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.