nothing500 Posted March 3, 2011 Share Posted March 3, 2011 I've been through quite a bit of research, trial, and error, but I know almost nothing about Linux, server-side programming, email, or PHP's PEAR library -- all of which, i'm using I've got a PEAR Mail 'send' WORKING JUST FINE FROM MY OWN PERSONAL SERVER on a PHP page. On a client's server, I've got linux w/ PHP and PEAR installed okay. But, sending mail from PHP or linux's "sendmail" function from their server is not working. (I'm not sure I'm using 'sendmail' correctly) BUT, I used linux's "Netcat" utility on that server to send mail just fine. My friend suggested I try changing the "sendmail_path" parameter in my "Mail::factory" call. I think this is a great idea. I've tried changing it once and I'm trying more paths now, but I can't think of all the paths that might lead to the email script my server is using. Default is "/usr/sbin/sendmail" and I've tried "/etc/mail/sendmail", also. So, I'd like to know: - possible sendmail script paths on linux - possible ways to test whether email is working on linux Here's my PHP code: $from = "[email protected]"; $to = "[email protected]"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $auth = false; $debug = true; $host = "fake.fake.fake.com"; $port = 25; $username = "[email protected]"; $password = "fakefakefake"; $sendmail_path = "/usr/sbin/sendmail"; $headers = array ( 'From' => $from, 'To' => $to, 'Subject' => $subject ); $smtp = Mail::factory('smtp', array ( 'host' => $host, 'port' => $port, 'auth' => $auth, 'username' => $username, 'password' => $password, 'sendmail_path' => $sendmail_path ) ); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } Link to comment https://forums.phpfreaks.com/topic/229433-cant-send-email-using-pear-mail-works-on-one-server-but-not-another/ Share on other sites More sharing options...
nothing500 Posted March 5, 2011 Author Share Posted March 5, 2011 My solution: $email = <<< EOF HELO smtp.server.com MAIL FROM: [email protected] RCPT TO: [email protected] DATA Body of email . QUIT EOF; $emailFile = fopen ('/tempEmailFileForSending.txt', 'w+'); fwrite ($emailFile, $email); shell_exec('nc -v smtp.server.com 25 < /tempEmailFileForSending.txt'); Link to comment https://forums.phpfreaks.com/topic/229433-cant-send-email-using-pear-mail-works-on-one-server-but-not-another/#findComment-1183083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.