Jump to content

[SOLVED] smtp help :(


sasori

Recommended Posts

I created a test mailing script and ofcourse i saved it on my localhost using wamp

i executed the script and it produces and error, ..the online version works fine

 

<?php

/**
* @author rmbapc
* @copyright 2008
*/
class emailer
{
private $sender;
private $recipients;
private $subject;
private $message;

function __construct($sender)
{
	$this->sender = $sender;
	$this->recipients = array();
}

public function addRecipients($recipient)
{
	array_push($this->recipients, $recipient);
}

public function setSubject($subject)
{
	$this->subject = $subject;
}

public function setMessage($message)
{
	$this->message = $message;
}

public function sendMail()
{
	foreach($this->recipients as $recipient)
	{
		mail($recipient, $this->subject,$this->message,"FROM: {$this->sender}\r\n");
		echo "mail successfully sent to {$recipient}";
	}
}
}

$testmail = new emailer("[email protected]");
$testmail->addRecipients("[email protected]");
$testmail->setSubject("testing only");
$testmail->setMessage("the quick brown fox jumps over the lazy dog");
$testmail->sendMail();


?>

 

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\test2\oop\index.php on line 39

mail successfully sent to [email protected]

 

 

the question is, what am i gonna add in the code so that i can make it work to send emails by just using my localhost ..i don't know what to do in the php.ini stuff

Link to comment
https://forums.phpfreaks.com/topic/118895-solved-smtp-help/
Share on other sites

your php.ini is telling php to send all mail to localhost:25 but i am guessing you dont have a SMTP server running on your server i would suggest fowarding all mail to your ISP buy change this line in your php.ini

; For Win32 only.
SMTP = localhost
smtp_port = 25

to

; For Win32 only.
SMTP = smtp.isp.com
smtp_port = 25

 

Scott.

 

Link to comment
https://forums.phpfreaks.com/topic/118895-solved-smtp-help/#findComment-612247
Share on other sites

your php.ini is telling php to send all mail to localhost:25 but i am guessing you dont have a SMTP server running on your server i would suggest fowarding all mail to your ISP buy change this line in your php.ini

; For Win32 only.
SMTP = localhost
smtp_port = 25

to

; For Win32 only.
SMTP = smtp.isp.com
smtp_port = 25

 

Scott.

 

 

this is kewl..its working now..thanks sir  :)

Link to comment
https://forums.phpfreaks.com/topic/118895-solved-smtp-help/#findComment-612250
Share on other sites

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.