You are not logged in.

#1 2009-10-12 08:35:37

miguimon
Member
From: Sydney
Registered: 2008-02-28
Posts: 37
Website

[SOLVED] Postfix and PHP mail function

Hey,

I recently installed a complete mail server using Postix + Courier POP3 + MySQL for multiple domains and for some weird reason I can't make use of the PHP mail function. The e-mail is send correctly but with no contents or information at all. I've been trying different things like changing the php.ini sendmail_path option but no results at the moment.

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -t -i -f info@domain.com

That is the output of /var/log/mail.log using the php form:

Oct 12 11:19:46 cadaques postfix/pickup[6020]: D626943EEF: uid=33 from=<http>
Oct 12 11:19:46 cadaques postfix/cleanup[6040]: D626943EEF: message-id=<20091012001946.D626943EEF@domain.com>
Oct 12 11:19:46 cadaques postfix/qmgr[21199]: D626943EEF: from=<http@domain.com>, size=322, nrcpt=1 (queue active)
Oct 12 11:19:47 cadaques postfix/qmgr[21199]: D626943EEF: removed
Oct 12 11:19:47 cadaques postfix/smtp[6045]: D626943EEF: to=<example@gmail.com>, relay=gmail-smtp-in.l.google.com[209.85.222.47]:25, delay=0.44, delays=0.02/0.12/0.1/0.19, dsn=2.0.0, status=sent (250 2.0.0 OK 1255306756 13si7763507pzk.25

Postfix main.cf configuration:

alias_database = $alias_maps
alias_maps = hash:/etc/postfix/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
mydestination = localhost
mydomain = domain.com
myhostname = domain.com
mynetworks = 127.0.0.0/8
mynetworks_style = host
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
relay_domains = *
sample_directory = /etc/postfix/sample
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.key
smtpd_tls_loglevel = 1
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 5000
virtual_transport = virtual
virtual_uid_maps = static:5000

Form:

<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='info@domain.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've received your information"
if($send_contact){
echo "We've received your contact information";
}
else {
echo "ERROR";
}
?>

No idea where to go from here.. anyone who had similar problems?

Thanks a lot!

Last edited by miguimon (2009-10-15 04:24:33)

Offline

#2 2009-10-12 09:31:47

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,223
Website

Re: [SOLVED] Postfix and PHP mail function

miguimon wrote:
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='info@domain.com';

$send_contact=mail($to,$subject,$message,$header);

<SNIP>

Where does $subject, $detail and $customer_mail get set? From what you've posted, they will be unassigned variables so an empty e-mail is to be expected.

Offline

#3 2009-10-15 04:23:59

miguimon
Member
From: Sydney
Registered: 2008-02-28
Posts: 37
Website

Re: [SOLVED] Postfix and PHP mail function

Solved!! The error was on the PHP form script, I found a different one and yeah it works very well.

Offline

Board footer

Powered by FluxBB