Jump to content

working with php mail() function


ethereal1m

Recommended Posts

Dear experts,

I try to send email using mail() with hmailserver as email server but it doesn't work. I can send email using pear Mail::factory without problem though.

 

Suppose I have this simple script:

$to = "[email protected]";
$subject = "diamond";
$message = "diamond";
$from = "[email protected]";
$headers = "From: $from";
if (mail($to,$subject,$message,$headers)) {
echo "Mail Sent.";
} else {
echo "Mail is not sent.";
}

with the following config in php.ini:

; For Win32 only.
SMTP = "ethereal1m.no-ip.org"
smtp_port = 25

; For Win32 only.
sendmail_from = "[email protected]"

 

PHP log doesn't show anything when the script is executed, even though mail() returns to "true". And also the recipient doesn't receive anything.

 

If I use pear Mail::factory, I can specify my server authentication parameters as oppose to using mail(). So I disable the outgoing SMTP on the server side.

 

However, php log and mail server log doesn't show me anything, meaning the server doesn't receive anything from mail() even the scripts claims that it sends something. Also I'm using php 5.2 and logging on mail only support for php version starts from 5.3.

 

What is the best way to troubleshoot this and narrow down the problem?

 

Best regards,

ethereal1m

Link to comment
https://forums.phpfreaks.com/topic/191330-working-with-php-mail-function/
Share on other sites

I got it.

since my client and server are in one machine:

SMTP = "127.0.0.1"

 

Also I had this piece of line:

sendmail_path =

which disables the script.

 

So I commented it out:

;sendmail_path =

 

And bam!, works like a charm! Man, talk about a small thing but very crucial.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.