Is it possible to use Google's mail server for testing purpose,and replace the address of mail server when my own server is ready?
Yes google does offer that via smtp.
smtp.google.com
port: 587
You also will need your google username and password to send emails.
You need a php smtp class. PHPMailer has one.
You can just send your mails via smtp.gmail.com
(port 465 or 587) as with any email client. Note anyway that you will need a Google email account for this. More details are here: Configuring email clients for using GMail
If you run a Windows server you can just do this (if you have access to the php.ini). Otherwise follow Sarfraz suggestion.
<?php
ini_set('sendmail_from','[email protected]');
ini_set('SMTP','smtp.test.net');
mail(...);
?>
I suggest you to use phpmailer, this is an example working code with it:
<?php
include_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
// enable SMTP authentication
$mail->SMTPAuth = true;
// sets the prefix to the server
$mail->SMTPSecure = "ssl";
// sets GMAIL as the SMTP server
$mail->Host = 'smtp.google.com';
// set the SMTP port
$mail->Port = '465';
// GMAIL username
$mail->Username = '[email protected]';
// GMAIL password
$mail->Password = 'your-gmail-password';
$mail->From = 'email address who send the email';
$mail->FromName = 'yourname';
$mail->AddReplyTo('email to reply', 'name to reply');
$mail->Subject = 'Test Gmail!';
if($is_your_mail_an_html){
$mail->MsgHTML($html_message);
$mail->IsHTML(true);
}else{
$mail->Body = $text_message;
$mail->IsHTML(false);
}
$mail->AddAddress('to address email', 'to name');
if(!$mail->Send()){
echo = $mail->ErrorInfo;
}else{
$mail->ClearAddresses();
$mail->ClearAttachments();
}
?>
But even without phpmailer, you can use gmail to send emails; Just set the port to 465 and enable the ssl auth.
P.s.: dont try to send nesletter throught gmail; they will block your account for 1 day if you send more than $x email per day ($x is 500 on the google documentation, but my experience say that is around 85!)