Environment:
Very recent install of Ubuntu 16.04.1
Fresh Install of XAMPP 7.0.8
Installed Postfix and mailutils
Initially attempted to use system to send mail, but changed to use gmail. Had authentication issues but all were solved.
I sent an email using the following mail command in the terminal, which sent successfully.
- Code: Select all
echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com
I was using example PHP code to send mail, and I put in valid addresses in exchange for the example ones. PHP failed to send the emailt
- Code: Select all
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
The configuration from php.ini for mail:
- Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=localhost
; http://php.net/smtp-port
smtp_port=25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; 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"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=On
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log =
When I attempted to send PHP mail with the mail() function, the Apache error log filled up with this message (and sometimes in the mail.log, on occasion, but usually nothing showed up there):
- Code: Select all
/usr/sbin/sendmail: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
/usr/sbin/sendmail: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
/usr/sbin/sendmail: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
/usr/sbin/sendmail: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
/usr/sbin/sendmail: /opt/lampp/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
After a fair amount of research, I found this post (http://stackoverflow.com/questions/20729067/php-shell-command-error-glibcxx-3-4-9-not-found) that helped me finally solve the problem. I have created this post since the other one is not directly about sending emails through postifx using PHP in XAMPP, and was difficult to find searching for solutions for this particular situation.
The fix was to replace /opt/lampp/lib/libstdc++.so.6 with /usr/lib/x86_64-linux-gnu/libstdc++.so.6. After restarting Apache, emails started working again.
I assume that file replacements such as this should not normally be necessary, which is why I described this as a bug.