Mailing in php
Moderator: General Moderators
Mailing in php
How could i mail using php?
Re: Mailing in php
This is the error thrown everytime i try wh the mail function. should i do some configuration changes? Whats going wrong?
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\test\test.php on line 2
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\test\test.php on line 2
Re: Mailing in php
In your php.ini file, you can specify the address of an SMTP server that will send email out for you. You may be able to put the address of your ISP's SMTP server in there.
It would look something like this when you're done.
It would look something like this when you're done.
Code: Select all
[mail function]
; Setup for Windows systems
SMTP = smtp.my.isp.net
sendmail_from = me@myserver.comRe: Mailing in php
Thanx for the reply.
But I am currently trying in my system(localhost). So I have mentioned smtp = localhost in my ini file.
But I am currently trying in my system(localhost). So I have mentioned smtp = localhost in my ini file.
Re: Mailing in php
Somebody help me out guys. I have been
for a while
Re: Mailing in php
Do you have an SMTP server installed?
- turbolemon
- Forum Commoner
- Posts: 70
- Joined: Tue Jul 14, 2009 6:45 am
- Location: Preston, UK
Re: Mailing in php
That would only work if you were running an SMTP server on your local machine. Assuming that you don't, if you have an external SMTP provider, for example a Gmail account or your ISP, you could probably test using those details.
Re: Mailing in php
Valid point.
But nope. I thought apache acts as one.
What am i supposed to do,install a smtp server? IF so, any good suggestions.
But nope. I thought apache acts as one.
What am i supposed to do,install a smtp server? IF so, any good suggestions.
Re: Mailing in php
I tried using gmail.
This neither gave me an error nor send me a mail
Code: Select all
class gMailer extends PHPMailer {
/** CHANGE THESE AS REQUIRED **/
public $From = "rzphpmailer@gmail.com"; //PUT YOUR ADDRESS HERE
public $FromName = "rzphpmailer"; //PUT YOUR NAME HERE
public $Password = "***********"; //PUT YOUR PASSWORD HERE
/** DO NOT CHANGE THESE **/
public $Host = "smtp.gmail.com";
public $Mailer = "smtp";
public $WordWrap = 75;
public $Port = "465";
public $SMTPAuth = true;
public function __construct($debug = false){
$this->Sender = $this->From;
$this->Username = $this->From;
$this->SMTPDebug = $debug;
}
}
$mail = new gMailer(false); //change to true if you are having trouble
$mail->AddAddress('xxxxxxxxxxx@gmail.com', 'addressee name');
$mail->Body = "This is a test message";
$mail->Subject = "Test Message";
if ($mail->send()) {echo "mail sent";}
else{echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;};
Re: Mailing in php
I'm unfamiliar with phpmailer...
But you could try turning on error reporting. You are including the main phpmailer script right?
But you could try turning on error reporting. You are including the main phpmailer script right?
Re: Mailing in php
It was throwing me an error till i had the host as ssl://smtp.gmail.com. But i after i changed the host to smtp.gmail.com. It stopped prompting me with error but i couldn't receive a mail.
- turbolemon
- Forum Commoner
- Posts: 70
- Joined: Tue Jul 14, 2009 6:45 am
- Location: Preston, UK
Re: Mailing in php
With the earlier php warning posted by OP, I think error reporting is on.
Try changing the false to true - no idea what it does, but it might be interesting to see the result as you seem to be having "trouble".
Try echoing before and after the $mail->send() call. This may determine whether there is an issue with the phpmailer class silently failing. Some may call this shotgun debugging, but it's quick and effective
.
Code: Select all
$mail = new gMailer(false); //change to true if you are having troubleTry echoing before and after the $mail->send() call. This may determine whether there is an issue with the phpmailer class silently failing. Some may call this shotgun debugging, but it's quick and effective
Re: Mailing in php
I tried echoing before and after $mail->send(). Only the content be4 the call has been printed.
Re: Mailing in php
I understand you run your script at your own computer. I myself use XAMPP on my desktop computer for testing. It's a complete easy to install package of the php-parser, MySQL-db, Apache webserver and much more such as a mail programm called Mercury Mail which should enable you to run a mail server yourself. This might be what you need.