Hi i am writing a php code to send email from my exchange server to user. however, keep receiving the the Warning message below:
Warning: Unknown error in c:\phpdev5\www\mailtest2.php on line 5
my php code: - <?php
-
$to = "test1@example.com";
-
$subject = "Hi!";
-
$body = "Hi,\n\nHow are you?";
-
if (mail($to, $subject, $body)) {
-
echo("<p>Message successfully sent!</p>");
-
} else {
-
echo("<p>Message delivery failed...</p>");
-
}
-
?>
php.ini setting: - [mail function]
-
; For Win32 only.
-
-
SMTP = gss-exchange1.example.com
-
SMTP_Port = 25
-
-
; For Win32 only.
-
-
sendmail_from = test2@example.com
Can anyone pls tel me what's wrong with my code or php setting?
Thanks.
5 2293
wasco, you need to set up a real mailing server in order to send a real mail,
read more about mail() function on php.net ,
if you are on windows, try to use free smtp server http://www.softstack.com/freesmtp.html
if you are lucky mail will be sent !!!
also read abt setting up Gmail as SMTP server
@hitendrap
Hi Hitendrap,
Thanks for your reply.
I have downloaded and installed the free smtp server; no luck for me, keeping getting "Waiting for connections on Port#25; using DNS Server: 170.133.125.2 (my company dns)
Remember that DNS server is not a mailing server (you need to get the IP of mail server from ur network admin, the DNS server contains the MX record for the mail server)
Make sure you also ask for the port number once you get thr mail serevr IP and set the configuration in PHP.INI
while your mailing program is being executed, just watch the freesmtpserver window, it shows the recipients e-mail address with hourglass icon before that !
Hi Hitendrap,
I have added SMTP address(Given by Network admin) to the php.ini and received the following message when i execute my php program:
Warning: Unknown error in c:\phpdev5\www\mailtest3.php on line 7
my php code: - $to = "test1@gss.com";
-
$subject = "Test mail";
-
$message = "Hello! This is a simple email message.";
-
$from = "test2@gss.com";
-
$headers = "From: $from";
- mail($to,$subject,$message,$headers);
-
echo "Mail Sent.";
-
?>
Do i need to include the test2 (sender) user id and password in my php code in order to connect to my smtp mail server (exchange mail server)?
Thanks in advance!
Not necessary as far as the SMTP server allows without authentication.
and headers are optional in mail() function.
avoid writing words like test, example in mails even the addresses,
coz' some popular Mailing servers like Gmail, Yahoo may put your test mail in Spam OR even block the mail.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bruce W...1 |
last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They
worked a few days ago but they stopped working. The only thing I've done to
this Windows 2000 PC in this time was a...
|
by: Data Goob |
last post by:
This one has me stumped.
How did SuSE disable the mail() function in their RPM'd version of PHP?
( This is their install-version of PHP with RPMs not what you download
from PHP.net )
I have...
|
by: Tom Petersen |
last post by:
Ok, I'm 99.9999999999999999999% sure there haven't been any code changes,
since the date stamps of the code are older than any email 'failures'
The email piece quit working using the mail.send. ...
|
by: DigitalRick |
last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my
guestbook. It had been working fine untill I upgraded to Server 2003 (I am
also running Exchange 2003) all locally. I...
|
by: Dushyant |
last post by:
Hi everyone,
I am working on an application, where I need to mail some xml files as
attachments. I tried to use System.Diagnostic.Process class but it does not
provide any help for attaching a...
|
by: shror |
last post by:
hi every body,
i have a problem which is when i was checking my mail() form it work
fine but the problem is that the form configuration is not set
correctly, in details:
the from var is not...
|
by: Frank |
last post by:
Hi,
I am hoping to find out the differences between the
System.Net.Mail and System.Web.Mail.
Can some nice folks post the differences; or some urls which show the
differences?
Great Thanks...
|
by: nextpulse |
last post by:
On Fedora, using php5. The mail() function returns a success - but the
mail itself is not actually sent.
How do I go about debugging this? Do I need to do this at the linux
command level to ensure...
|
by: undbund |
last post by:
Hi I am creating a newsletter system. The software should run from
desktop computer (localhost) but be able to send email to anyone on
the internet. Can you guys give me some ideas on how to...
|
by: sui |
last post by:
this is my code
import sys, os, glob, datetime, time
import smtplib
## Parameters for SMTP session
port=587
SMTPserver= 'smtp.gmail.com'
SMTPuser= '...@gmail.com'
pw= 'fill in here'...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |