/    Sign up×
Community /Pin to ProfileBookmark

Ok, i have the following script to send mail thro SMTP on a XP pro machine.

[code=php]<?PHP
function valid_email($email) {
$regexp = “^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$”; //Validate the email address
$valid = 1; //Presume it is valid
if(eregi($regexp, $email)) {
return $valid;
}
}

if(isset($_GET[“task”]) && $_GET[“task”] != “”) {
if(isset($_POST[“email”]) && $_POST[“email”] != “”) {
if(isset($_POST[“subject”]) && $_POST[“subject”] != “”) {
if(isset($_POST[“message”]) && $_POST[“message”] != “”) {
if(isset($_POST[“cc”]) && $_POST[“cc”] != “”) {
if(valid_email($_POST[“email”])) {
if(valid_email($_POST[“cc”])) {
$headers = “From: “. $_POST[“email”] .”rn”;
$headers .= “Cc: “. $_POST[“cc”] .”rn”;
mail(“[email protected]”, $_POST[“subject”], $_POST[“message”], $headers);
echo “Your mail has been sent. We will get back to you shortly.”;
}else{
echo “The Cc email address’s you entered are not valid. Please go back and enter valid one(s).”;
}
}else{
echo “The email address you entered is not valid. Please go back and enter a valid one.”;
}
}else{
if(valid_email($_POST[“email”])) {
$headers = “From: “. $_POST[“email”] .”rn”;
mail(“[email protected]”, $_POST[“subject”], $_POST[“message”], $headers);
echo “Your mail has been sent. We will get back to you shortly.”;
}else{
echo “The email address you entered is not valid. Please go back and enter a valid one.”;
}
}
}else{
echo “You need to go back and enter a message.”;
}
}else{
echo “You need to go back and enter a subject.”;
}
}else{
echo “You need to go back and enter an email address.”;
}
}
?>[/code]

Now this script works with PHP installed and running on IIS 5(on XP Pro SP1). I tried putting it on a server 2k3(IIS 6) and when i submit the form(and it to send the mail) it doesnt bring up any errors and says everything was sent fine. however when i check my mail nothing is getting recieved….anyone have an idea on what’s wrong?

FYI:we tried another PHP send mail script another person made to make sure mine wasn’t screwy and it did the same thing. it says it send it but in reality it doesnt.

any help or ideas is appriciated.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJan 11.2005 — Are you sure that the SMTP server is running and properly configured on the 2k3 machine? Maybe you should try using an ASP.Net sendmail function to see if that works, and if it does then you know it's a PHP-specific problem.
Copy linkTweet thisAlerts:
@GenixdeaeauthorJan 11.2005 — u dont happen to know how to build an asp.net one do u? I dont know nething about asp.net so...

i was told by another person that you have to configure the php.ini file differantly on a 2k3 server machine then xp pro. and so i made a few changes(like i put in a mail.domain.com in the SMTP =)...
Copy linkTweet thisAlerts:
@ExuroJan 11.2005 — Place this code in an ASPX file (such as "test.aspx") on your server, and when you visit the page it should automatically send the email:
&lt;% @Import Namespace="System.Web.Mail" %&gt;
&lt;script language="C#" runat="server"&gt;
void Page_Load(Object src, EventArgs E) {
try {
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send("[email protected]","[email protected]","Subject","Message");
Response.Write("&lt;h1&gt;Mail Sent&lt;/h1&gt;n");
}
catch (Exception ex) {
Response.Write("&lt;h1&gt;Send Mail Error&lt;/h1&gt;n");
}
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@GenixdeaeauthorJan 22.2005 — ok, the aspx one worked so it is php...but what could it be?
Copy linkTweet thisAlerts:
@ExuroJan 22.2005 — Is your [FONT=courier new]sendmail_path[/FONT] set to [FONT=courier new]null[/FONT], and your [FONT=courier new]SMTP[/FONT] set to [FONT=courier new]localhost[/FONT] in your INI file?
Copy linkTweet thisAlerts:
@GenixdeaeauthorJan 22.2005 — ok, figured it out. when we had the ini file set to localhost for the SMTP and the Smtpfrom_mail(or sumtin like that) was set to blank it didnt work. that aspx script gave me an idea of trying to put 127.0.0.1 instead of localhost. so i set SMTP = 127.0.0.1 and Smtpfrom_mail = [email protected] and it worked!

anyways thanks for the help guys ?
×

Success!

Help @Genixdeae spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...