Jump to content

php email


bob302

Recommended Posts

I am trying to send email from localhost using my isp.  not having success...below is current config.

I have tried many of these and they all give me the same message about smtp, port error, etc......I have even reinstalled wampserver2 thinking I may have don something wrong.....I read the forums and still get errors. Here is my current config....

[mail function]

; For Win32 only.

; http://php.net/smtp

SMTP = localhost

; http://php.net/smtp-port

smtp_port = 25

 

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = rlv302@att.net

 

<?php

$to = "gypsy571@yahoo.com";

$subject = "Test mail";

$message = "Hello! This is a simple email message.";

$from = "rlv302@att.net";

$headers = "From: $from";

mail($to,$subject,$message,$headers);

echo "Mail Sent.";

?>

Error message received:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\cccga\testmail.php on line 10

Mail Sent. >

 

ANy help greatly appreciated

Link to comment
Share on other sites

Generally your isp will require authentication to use there smtp servers, this is not supported by php's mail function which expects a local mail server to be installed. In fact, the configuration you have shown us is still attempting to use an smtp server on localhost.

 

Anyway, your best bet is to either install a mail server locally or to use a third party mail library like PHPMailer which can connect and authenticate to remote servers.

Link to comment
Share on other sites

well I installed phpmailer....here is scrip;t and error

<?php

 

 

require("class.phpmailer.php");

 

 

$mail = new PHPMailer();

 

 

 

$mail->IsSMTP();  // telling the class to use SMTP

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl"; // sets the prefix to the servier

$mail->Host = "smtp.att.yahoo.com"; // sets GMAIL as the SMTP server

$mail->Port = 465; // set the SMTP port

$mail->Username = "rlv302@att.net"; // GMAIL username

$mail->Password = "magyar302"; // GMAIL password

$mail->From = "rlv302@att.net";

$mail->FromName = "cccga";

$mail->AddAddress("rlv302@att.net");

$mail->Subject = "Test PHPMailer Message";

 

$mail->Subject  = "First PHPMailer Message";

$mail->Body = "Hi! \n\n This was sent with phpMailer_example3.php.";

$mail->WordWrap = 50;

 

 

if(!$mail->Send()) {

 

echo 'Message was not sent.';

 

echo 'Mailer error: ' . $mail->ErrorInfo;

} else {

 

echo 'Message has been sent.';

}

?> 

 

 

error

SMTP Error: Could not connect to SMTP host. Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.