-3

how to send Mail from localhost using PHP?

sending mail from localhost to remote server

i am using wamp server,OS windows Xp.

can anyone tell me about this issue

thank u in advance

  • 3
    Well....tell us the ways which you have tried... – Flukey Dec 15 '11 at 11:41
  • 1
    If you tried "all ways" then there's not much we can offer, is there? – TRiG Dec 15 '11 at 11:43
  • what is a "localhost remote server" ? – Rufinus Dec 15 '11 at 11:45
  • Sending emails doesn't really require a real smtp server, it's just a request to such a server, so as long as you have internet, and know the standard of mail protocol you should have no worries relating to this. – khael Dec 15 '11 at 12:02
  • hooo..ok let me tell.first one is 1.changed smtp setting in PHP.ini file.do u know where is it?it is your wamp/xamp server...second one is changing the incoming mail server in php.ini file.. – ananthi arumugam Dec 15 '11 at 12:04
  • hello TRiG...i tried what ways i know..i just want u to tell some thin u know...ok i think now u understood... – ananthi arumugam Dec 15 '11 at 12:08

2 Answers2

2

Windows: You need to configure SMTP on your localhost. More info

EDIT:

Linux: How to send email from localhost using PHP on Linux

Community
  • 1
  • 1
SlavaNov
  • 2,447
  • 1
  • 18
  • 26
0

Got a gmail account? Yes? cool! As this will be the simplest solution for you. If not, you can use this library to connect to any other SMTP server. Let's use Gmail to send an email from our PHP script, here goes:

Download the SwiftMailer library from here: http://swiftmailer.org/download

# get the library
require_once 'Swift/lib/swift_required.php';

# setup the transport

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
  ->setUsername('yourusername@gmail.com')
  ->setPassword('yourpassword');

$mailer = Swift_Mailer::newInstance($transport);

# create our message

$message = Swift_Message::newInstance('Hello World!')
  ->setFrom(array('from@email.com' => 'Skynet'))
  ->setTo(array('to@email.com' => 'Terminator'))
  ->setBody('What would you like to say in the email?');

# send the message! hooray!

$mailer->send($message);
Flukey
  • 6,445
  • 3
  • 46
  • 71