ethereal1m Posted February 8, 2010 Share Posted February 8, 2010 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 More sharing options...
trq Posted February 8, 2010 Share Posted February 8, 2010 The mail function is not capable of sending authentication data. if you need to authenticate a connection to your smtp server, mail() is of no use to you. Link to comment https://forums.phpfreaks.com/topic/191330-working-with-php-mail-function/#findComment-1008736 Share on other sites More sharing options...
ethereal1m Posted February 8, 2010 Author Share Posted February 8, 2010 ok, I think the problem is not authentication at this point since php log and server log don't show anything. Could you suggest the first step to troubleshoot this? Link to comment https://forums.phpfreaks.com/topic/191330-working-with-php-mail-function/#findComment-1008740 Share on other sites More sharing options...
ethereal1m Posted February 9, 2010 Author Share Posted February 9, 2010 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. Link to comment https://forums.phpfreaks.com/topic/191330-working-with-php-mail-function/#findComment-1009535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.