Could not execute: /var/qmail/bin/sendmail but only on localhost - works online

Hi all,

This below fine except I haven’t edited the site for about 5-6 months and something got changed somehow, though I don’t remember amending anything myself.

The issue concerns sending email via PHP’s:

$mail = new PHPMailer();
$mail->IsSMTP();
etc
.

I now can only get it to work on localhost OR online but not both at the same time.

To make it work offline (on localhost) I need to change following in class.phpmailer.php

FROM

public function IsSMTP() {
$this->Mailer = ‘smtp’;
}

TO

function IsSMTP() {
$this->IsSendmail();
}

To make it work online I need to do the opposite.

If I leave it as $this->IsSendmail(); for localhost I get the error message “Could not execute: /var/qmail/bin/sendmail”. If however I leave it as $this->Mailer = ‘smtp’; then once executed online I get an error message suggesting it can’t connect to the SMTP server (which I know it can if only I change it back to $this->IsSendmail();

I’ve searched online and everything seems to point to editing php.ini from smtp = localhost to my SMTP server but this doesn’t seem to work for me, same symptoms persist.

Does anyone here know where the logic lies with this one?

P.S. I’m using WAMP for localhost.

Many thanks,

Hi netsearchmonkey,

Are you sure your SendMail service is running on the server/machine where your WAMP stack is located?

The reason you need to change this directly to your SMTP server is that either PHP does not have the right permissions to send via SendMail or SendMail is not working.

Steve

Thanks for your reply. It’s running (the SendMail service) as far as I can tell, where would you suggest I fully check this out?

For now I’ve come with a crude yet working solution thus far by doing the following in class.phpmailer.php:

public function IsSMTP() {
if($_SERVER[‘HTTP_HOST’] == ‘localhost’){
$this->Mailer = ‘smtp’;
} else {
$this->IsSendmail();
}
}

This now works both on localhost and online. I didn’t have to do this before when I remember it working (about 6 months ago when I last tested this feature) but it seems to be the simplest way out.

On a fresh WAMP install the only Apache module I need to enable is url_rewrite and edit the above in class.phpmailer.php. I don’t recall ever having to start/configure SendMail services. I thought I had to install an additional SMTP server for localhost (there was a time when I remember googling for smtp servers) though today after taking a closer look at my laptop (my main developer system till now) I can’t find any reference to an SMTP server installed, and WAMP also produced the same error message unless tweaked accordingly as above. The php.ini is left at default with smtp = localhost. All the server login credentials are provided when I setup the PHPMailer(); object.

So unless I’m missing somewhere there’s likely two ways to go fix it. Somewhere there has to be an incorrect/missing SendMail setting meaning $this->Mailer = ‘smtp’; has to be used on localhost (and this isn’t obvious or easy to remember each time a new fresh install of WAMP is performed on a different developer system) OR the above crude if/else is a quick easy and only fix to get it running.

Which is the professional way of fixing it? I’m not sure…

Hi,

What O.S. are you on - by the var/… path it seems like Linux? If it is Linux something then you can use:

[LEFT][COLOR=#000000][FONT=verdana]ps aux | grep sendmail[/FONT][/COLOR][/LEFT]

[LEFT]. If nothing appears in your command line like:

Check your mail logs:
/var/log/mail
then sendmail is not running. If it is then it is likely a permission problem as sendmail normally runs as ROOT and php may not have ROOT privileges. I do not know how to check it on Windows.[COLOR=#000000][FONT=verdana]

I agree with you that you are doing a hack and it is better to understand why it is not working and fix it. But if you don’t have a lot of sendmail experience this can be a really hairy process.

If you are successful at routing a message using SMTP then somewhere a host file is set to a valid smtp server. Nowadays due to SPAM you have to be careful what SMTP server you use as many receiving hosts will reject messages if your SMTP banner does not match your email banner.

Steve[/FONT][/COLOR][/LEFT]

Thanks again.

I’m on Windows personally as is localhost (Windows Vista (laptop) and Windows 7 (desktop)). Hosting is Linux.

For the STMP server I’m using 1&1’s. All test messages come through it seems and aren’t detected as SPAM.

I’m not sure why the havoc other than online they must either have something setup differently with the SendMail service or they have Qmail installed hence the path to the SMTP app is valid.

Why I would prefer to keep solutions professional I’m not too bothered with the crude method as its only so I can dry test the code offline before I upload it to a live website.