Forum Moderators: coopster
_______________________________________________
I able to connect my mail server using outlook .I can receive and send emails using outlook, but when I tried to send an email using php scrpit.I got above error.
I think everything is ok about SMTP AND PORT.
you can see below
<snipped specifics>
________________________________________________
php.ini file config.
[mail function]
; For Win32 only.
SMTP = nnn.nnn.nnn.nnn
smtp_port = 25
; For Win32 only.
sendmail_from = support@example.net
_________________________________________________
I'm using windows local authentication for incoming/outgoing message
OS- windows server 2003,
webserver apache 2.0.52 php 5.0.3
___________________________
here is code
<?php
$to = "Admin <support@example.net>";
$subject = "This is a test email";
$message = "Dear John,\n\nThis is a fake email, I hope you enjoy it.\n\nFrom Jane.";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if (mail($to,$subject,$message, $headers))
{
echo "<h4>Thank you for sending email</h4>";
}
else
{
echo "<h4>Can't send email to $to</h4>";
$error = (isset($php_errormsg))? $php_errormsg : '';
echo $error;
}
?>
_________________________________________________
really I do not understand whats wrong. do I need to change something in my httpd.config
[edited by: coopster at 2:49 am (utc) on Feb. 1, 2005]
[edit reason] generalized ip, url and email [/edit]
I have scoured the net looking for an answer or what to test to no avail. I am using apache, php on windows.
Any further ideas would be appreciated.
You may want to have a look at your SMTP settings in your
php.inifile. Short details can be found in message #2 in the Installing PHP5 Under Windows XP and Apache [webmasterworld.com] thread in the PHP Forum Library [webmasterworld.com].
phpsytesnet, your configuration settings look correct at first glance here. Along with jatar_k's recommendations, since you seem to be running your own SMTP server, have you checked the logs there yet? Is it being blocked because of some spam filtering or otherwise? If not, this may be the old mail() and CRLF vs LF [webmasterworld.com] issue...
; For Win32 only.
sendmail_from = myemailaddress
--------------------------------------
Is there anything else i have to do (naturally i replace the relevant mail and from with my actual servers etc).
I am wonder if there is something my ISP has done to not allow me to send email via a php script seeing i can use outlook to send and receive email using the same mail server.
Any ideas.
I'm just setting up a test server environment on a computer at home to learn a bit of PHP but I can't get past this SMTP error when using the mail() function. So I am not too worried about security since it's just a test environment... I am not sure if this is an issue with trying to auto-validate the SMTP connect. Any more thoughts. Thanks in advance!
I have often pondered that too, jatar_k. How does it work on my server from home when sending email through my ISP which requires authentication? (I can always fall back on one of the external servers, but typically I just throw the ISP's mail server into the directive and I'm good to go.) However, I have my email client checking the mailbox every 5 minutes too, so there likely is my answer.
"We would like to inform you that the SMTP path being used by you is correct. But in your php mail() function, you have not used the setting for My Server Requires Authentication, which is essential to send email to SBC Server. Hence, please use the appropriate commands/script to provide the said setting in your php mail()function."
So from this it sounds like there is some sort of "My Server Requires Authentication" parameter for the php mail() function. Has anyone heard of this added bit of code instruction? It seems to me that there could be some validation within the code then this would work. It's just whether this is a vaild part of the php language.
I hope this question isn't too naive. I'm just getting started. Thanks!
[phpmailer.sourceforge.net...]
---------------------------------------------------
testmail.php (from above site)
--------------------------------------------------
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.pacbell.yahoo.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "pkellogg@pacbell.net"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("pkellogg@pacbell.net","Patrick Kellogg");
// $mail->AddAddress("ellen@site.com"); // optional name
//$mail->AddReplyTo("info@site.com","Information");
$mail->WordWrap = 50; // set word wrap
// $mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
// $mail->AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the <b>HTML body</b>";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
--------------------------------------------------
pfk