qmail send two identical mails via php mail() [qmail-inject]

Sorry for my english and i'm learning using Freebsd 6.0 so i have no idea where i may search for errors in configuration files.

THE PROBLEM:
I have uninstall sendmail and i've instaled qmail on FreeBSD to send messages via PHP function: mail().
In php.ini i have:
Code:
sendmail_path = /var/qmail/bin/qmail-inject
This configuration sends e-mail but i've got on my mailbox (different host) two identical mails. Why??
The PHP script is working fine on windows with smtp server so it's ok.

I have no idea where to start looking...

Looking forward to getting an answer
 
You uninstalled Sendmail? You actually removed it from the base system? And you installed qmail in such a way that it ends up in /var/qmail? Have you read The Handbook? I wonder if anyone can (or will) help you with a severely outdated version of FreeBSD and a non-standard (de)installation of software.
 
Yes i uninstall sendmail brutaly. I've chenaged line in rc.conf file 'sendmail_enable="NO"' and i've deleted the main running file 'sendmail' from somewhere (dont remember). But i'm sure sendmail isn't working (when system starts i got errors with 'i can't find sendmail' or something). Next i've moved 'sendmail' files from /usr/lib and /usr/sbin to files 'sendmail.bak'.

I didnt read The Handbook becouse where is nothing about qmail. But I've read this: freebsddiary.org/qmail.php exept installing qpopper. For now I only want to have SMTP server localy to send e-mail from PHP.
 
I think you're in a complete mess. Read the ports section in the Handbook and then the section about MTAs. Next time, install qmail using ports since it's a better option.
 
i've installed qmail from ports: 'make install clean' with no special configure options (default).
 
Oops. I just looked at the port and found out that it does install to /var/qmail by default. Usually files are installed to /usr/local.

Take a look at /var/log/maillog and see why it's being sent twice.
 
from /var/maillog:
Code:
Oct  1 08:37:56 server qmail: 1254386276.229893 new msg 260
Oct  1 08:37:56 server qmail: 1254386276.230811 info msg 260: bytes 1049 from <anonymous@server.domain.com> qp 4547 uid 1004
Oct  1 08:37:56 server qmail: 1254386276.356553 starting delivery 5: msg 260 to remote my_mail@o2.pl
Oct  1 08:37:56 server qmail: 1254386276.378653 status: local 0/10 remote 1/20
Oct  1 08:37:56 server qmail: 1254386276.401454 starting delivery 6: msg 260 to remote my_mail@o2.pl
Oct  1 08:37:56 server qmail: 1254386276.402124 status: local 0/10 remote 2/20
Oct  1 08:37:56 server qmail: 1254386276.668155 delivery 6: success: 193.17.41.214_accepted_message./Remote_host_said:_250_OK_queued_as_nbjSvA/
Oct  1 08:37:56 server qmail: 1254386276.669026 status: local 0/10 remote 1/20
Oct  1 08:37:56 server qmail: 1254386276.871102 delivery 5: success: 193.17.41.123_accepted_message./Remote_host_said:_250_OK_queued_as_hnthXK/
Oct  1 08:37:56 server qmail: 1254386276.872193 status: local 0/10 remote 0/20
Oct  1 08:37:56 server qmail: 1254386276.872827 end msg 260
 
I can't really see any problems from the log. Check your PHP script to see if you accidentally configured it to send mail twice.
 
  • Thanks
Reactions: mxm
Yep. The script was the problem but why??

I wrote some simple script test:
PHP:
<?php
	// Headers
	$naglowki = 'MIME-Version: 1.0' . "\r\n";
	$naglowki .= 'To: [email=my_mail@o2.pl]my_mail@o2.pl[/email]'."\r\n";
	$naglowki .= 'From: Me <no-reply@no-reply.pl>' . "\r\n";				
	// Subject
	$temat = 'Testing';
	// Message
	$wiadomosc = "TEST";
	// Sending
	if( ! @mail([email='my_mail@o2.pl]'my_mail@o2.pl[/email]', $temat, $wiadomosc, $naglowki))
		die('Sorry...');
?>
The same. I've got two identical mials in log.

And other simple script without headers:
PHP:
<?php
	// Sending
	if( ! @mail([email='mxm_one@o2.pl]'mxm_one@o2.pl[/email]', "Subject", "TEST"))
		die('Sorry...');
?>
Yep. Only 1 message in box.

So I've got question why i can't use headers in qmial via PHP mail() function?? Qmail isn't good for PHP??
 
mxm said:
Yep. The script was the problem but why??

I wrote some simple script test:
PHP:
<?php
	// Headers
	$naglowki = 'MIME-Version: 1.0' . "\r\n";
	$naglowki .= 'To: [email=my_mail@o2.pl]my_mail@o2.pl[/email]'."\r\n";
	$naglowki .= 'From: Me <no-reply@no-reply.pl>' . "\r\n";				
	// Subject
	$temat = 'Testing';
	// Message
	$wiadomosc = "TEST";
	// Sending
	if( ! @mail([email='my_mail@o2.pl]'my_mail@o2.pl[/email]', $temat, $wiadomosc, $naglowki))
		die('Sorry...');
?>
The same. I've got two identical mials in log.

And other simple script without headers:
PHP:
<?php
	// Sending
	if( ! @mail([email='mxm_one@o2.pl]'mxm_one@o2.pl[/email]', "Subject", "TEST"))
		die('Sorry...');
?>
Yep. Only 1 message in box.

So I've got question why i can't use headers in qmial via PHP mail() function?? Qmail isn't good for PHP??

This should be unrelated to qmail although I'm not completely sure. I'm hopeless at PHP right now, but how about removing the "To" header?
Code:
	// Headers
	$naglowki = 'MIME-Version: 1.0' . "\r\n";
	$naglowki .= 'From: Me <no-reply@no-reply.pl>' .

Try and see if it works.
 
  • Thanks
Reactions: mxm
I've done some tests. So if u want have header: "To: ...@..." u must use function mail() without address in first argument. Example:
PHP:
<?php 
    // Headers 
    $naglowki = 'MIME-Version: 1.0' . "\r\n"; 
    $naglowki .= 'To: [email=my_mail@o2.pl]my_mail@o2.pl[/email]'."\r\n"; 
    $naglowki .= 'From: Me <no-reply@no-reply.pl>' . "\r\n";                 
    // Subject 
    $temat = 'Testing'; 
    // Message 
    $wiadomosc = "TEST"; 
    // Sending 
    if( ! @mail('', $temat, $wiadomosc, $naglowki)) 
        die('Sorry...'); 
?>
Of course the example above is also a good move.

So the problem is SOLVED :)
 
Back
Top