Sending mail with mail() function and sendmail (Linux)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mastropiero
Forum Newbie
Posts: 3
Joined: Thu Mar 06, 2008 7:12 am

Sending mail with mail() function and sendmail (Linux)

Post by Mastropiero »

Hi,

I'm trying to send a mail by using the mail() function but it doesn't work :-(

The php.ini is ok (the path to sendmail executable is correct) and the sendmail works fine when executed from command-line.

The mail() function gets an error without actually attempting to invoke the sendmail command (the /var/log/maillog says 'nothing').

I thought it was a permissions issue so I granted execution permission for everyone but it didn't work.

Any idea?

Thanks in advance.
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: Sending mail with mail() function and sendmail (Linux)

Post by Sekka »

Are no errors being displayed for debugging?

Try the following code before the mail() is run, and if a problem occurs, an error should be thrown.

Code: Select all

error_reporting (E_ALL);
ini_set ("display_errors", true);
Mastropiero
Forum Newbie
Posts: 3
Joined: Thu Mar 06, 2008 7:12 am

Re: Sending mail with mail() function and sendmail (Linux)

Post by Mastropiero »

Sekka wrote:Are no errors being displayed for debugging?

Try the following code before the mail() is run, and if a problem occurs, an error should be thrown.

Code: Select all

error_reporting (E_ALL);
ini_set ("display_errors", true);
Nothing happens :-(

The mail() result is still "false" (of course the mail is not sent) and no other error is displayed.

:-(
User avatar
Sekka
Forum Commoner
Posts: 91
Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK

Re: Sending mail with mail() function and sendmail (Linux)

Post by Sekka »

Trying using something like PHPMailer or Swift Mailer.

They are pre-built code packages for sending mails, both very good.

PHPMailer using the server's mail() function and SMTP, where as Swift is SMTP only.
Mastropiero
Forum Newbie
Posts: 3
Joined: Thu Mar 06, 2008 7:12 am

Re: Sending mail with mail() function and sendmail (Linux)

Post by Mastropiero »

Sekka wrote:Trying using something like PHPMailer or Swift Mailer.

They are pre-built code packages for sending mails, both very good.

PHPMailer using the server's mail() function and SMTP, where as Swift is SMTP only.
Ok. I've installed PHPMailer and it says that fsock is missing. :S

I've installed the php-devel package. Is it enough, or I have to recompile PHP?

Thanks again.
Post Reply