0

Hello,

I am working on a project in php.Now i want to send a mail to any e-mail id.

How can i send it?

Is there any mail API for PHP there or not?
because right now i am running project on localhost(for testing).After completion of it i will upload it to web hosting server.

So can i send a mail from localhost to any e-mail id usinh PHP?

Thanks.

5
Contributors
5
Replies
28
Views
4 Years
Discussion Span
Last Post by Jamblaster
1

You can temporarily use a service provider such as GMail, Yahoo and Hotmail for testing your script, even locally.

I always use the PHPMailer class (It's active on 3 projects of mine) and it hasn't let me down once.

Michael

0

can i send mail without using PHPMailer class?

Is it possible to send mail through Socket in php?

1

If you have a working SMTP email server installed on your web-server then you can use a simple PHP function to send mail:

mail($to, $subject, $body, $headers);

Headers are optional, but if you want to use them you prepare the $headers variable like this:

$headers = "From: Example@Email.com \r\n";
$headers.= "CC: Exampl3@Email.com \r\n";

Each header needs to use both \r and \n to work correctly.

To prepare the body nicely you can prepare it like this before sending it:

$body = wordwrap($body, 70);

You can collect any or all of these variables through an HTTP interface so you could send an email anywhere with any subject, body, headers,...

It would use the configured SMTP server for your web-server and it would send it through port 25.

Edited by diafol: corrected code formatting

Votes + Comments
thanks a lot...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.