I want to use the mail() function from my localhost. I have WAMP installed and a Gmail account. I know that the SMTP for Gmail is smtp.gmail.com and the port is 465 (more info from gmail). What I need to configure in WAMP so I can use the mail() function?
Thanks!!
It's quite simple. (Adapt syntax for your convenience)
public $smtp = array(
'transport' => 'Smtp',
'from' => '[email protected]',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '[email protected]',
'password' => '*****'
)
i know in XAMPP i can configure sendmail.ini to forward local email. need to set
smtp_sever
smtp_port
auth_username
auth_password
this works when using my own server, not gmail so can't say for certain you'd have no problems
use stunnel on your server, to send with gmail. google it.
I've answered that here: (WAMP/XAMP) send Mail using SMTP localhost (works not only GMAIL, but for others too).
As an alternative to PHPMailer, Pear's Mail and others you could use the Zend's library
$config = array('auth' => 'login',
'ssl' => 'ssl',
'port'=> 465,
'username' => '[email protected]',
'password' => 'XXXXXXX');
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubj');
$mail->send($transport);
That is my set up in localhost server and I can able to see incoming mail to my mail box.
If you open the php.ini file in wamp, you will find these two lines:
smtp_server
smtp_port
Add the server and port number for your host (you may need to contact them for details)
The following two lines don't exist:
auth_username
auth_password
So you will need to add them to be able to send mail from a server that requires authentication. So an example may be:
smtp_server = mail.example.com
smtp_port = 26
auth_username = [email protected]
auth_password = example_password
I'm positive it would require SMTP authentication credentials as well.
PEAR: Mail worked for me sending email messages from Gmail. Also, the instructions: How to Send Email from a PHP Script Using SMTP Authentication (Using PEAR::Mail) helped greatly. Thanks, CMS!
Source: Stackoverflow.com