How to send an email in PHP?
Moderator: General Moderators
How to send an email in PHP?
I have this following code, but the time I run this code on my browser...
it has an warning ang error saying
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\New Folder\index.php on line 8
Mail Sent.
what shoud i do?
i uploaded the code asa well....
thanks
-rjuy
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<html>
<body>
</body>
</html>
it has an warning ang error saying
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\New Folder\index.php on line 8
Mail Sent.
what shoud i do?
i uploaded the code asa well....
thanks
-rjuy
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<html>
<body>
</body>
</html>
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: How to send an email in PHP?
what server are you running?
I bet I can guess...windows?!? If so you do not have a mailserver, so the email can not be sent
I bet I can guess...windows?!? If so you do not have a mailserver, so the email can not be sent
Re: How to send an email in PHP?
yes, i'm using windows....
thanks
i'll try this one
-rjuy
thanks
i'll try this one
-rjuy
Re: How to send an email in PHP?
how can i have a mailserver then in my sytem?
thanks
thanks
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: How to send an email in PHP?
I tried a while ago on windows many times and failed. So in the end I installed Linux Fedora and that had everything installed by default.
You can setup your apache (WAMP) to connect to a remote SMTP.
You can setup your apache (WAMP) to connect to a remote SMTP.
- zhaolei254
- Forum Newbie
- Posts: 1
- Joined: Mon Dec 08, 2008 10:52 pm
Re: How to send an email in PHP?
If you don't have smtp server !
Need socket!!
Need socket!!
Re: How to send an email in PHP?
You can setup your apache (WAMP) to connect to a remote SMTP. how?
i dont have any idea... Sorry..
Thanks,,
-rjuy
i dont have any idea... Sorry..
Thanks,,
-rjuy
Re: How to send an email in PHP?
1. Google wamp
2. Install
3. Send email(s)
2. Install
3. Send email(s)
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: How to send an email in PHP?
In the httpd.conf file about half way down you will see the stmp details. Modify it to your remote smtp. Then restart apache.
Re: How to send an email in PHP?
where is that? very sorry such a noobs here....
I really feel sorry for my self... New to web developement, and accept the fact that i'm not so good in configuration...
thanks,
-rjuy
I really feel sorry for my self... New to web developement, and accept the fact that i'm not so good in configuration...
thanks,
-rjuy
Re: How to send an email in PHP?
Don't feel sorry, but don't ask every detail either..... rarely someone will tell you exactly what todo step by step just like that. Show some willling and read some docs. I suggest you save some time and directly use http://swiftmailer.org/ There are examples ect...howto connect to server and so on.
Try out read and let us know how it goes.
Try out read and let us know how it goes.
Re: How to send an email in PHP?
thank u very much
-rjuy
-rjuy