tags:

views:

177

answers:

4

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?

A: 

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.

Sarfraz
Seems it's not available now?
The ort should ben 465, not 587 ;)
DaNieL
465 doesn't work,either.
try my code: http://stackoverflow.com/questions/1944957/how-to-send-email-without-my-own-mail-server-by-php/1945125#1945125
DaNieL
i have been using 587 till now successfully :)
Sarfraz
check this out: http://sarfraznawaz.wordpress.com/2009/09/10/quick-personal-emailer/
Sarfraz
hem, if you are trying to check with telnet command, `telnet smtp.gmail.com 587` works for me.
DaNieL
+1  A: 

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

Konamiman
I just tried,but the connection failed.
A: 

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(...);
?>
Christoffer
There is no such site as `smtp.test.net`
....LOL... smtp.test.net is an example, i guess..
DaNieL
But I need a live server,not sample.
+1  A: 

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!)

DaNieL
I'm running `telnet smtp.google.com 465` but failed to get connected.
donno abot telnet, but copy'n'paste the code i gave you, edit the parameters, and it should work (get phpmailer first!)
DaNieL
I know the steps to send email by PHP,but the prerequire is a mail server!
Ho, sorry i misunderstood, then read the link Konamiman gave you, it will explain setp-to-step how to interact with gmail
DaNieL