Jump to content


Photo

email script


  • Please log in to reply
22 replies to this topic

#1 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 22 February 2006 - 07:38 AM

I have been trying to get an email script to work for awihle, and nothing I do will work. I have tried the scripts from php.net/mail, and they will not work for me.

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Thats the code I use, and of course I changed it to my information. Any suggestions?

#2 alan543

alan543
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 February 2006 - 04:25 PM

This always works for me... Assuming you have posted the email_address from a form.


$email_address = $_POST['email_address'];
$subject = "Subject Here";
$message = "Message Here";
    
mail($email_address, $subject, $message, "From: Your Name<yourname@youraddress.com>\nX-Mailer: PHP/" . phpversion());


#3 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 22 February 2006 - 04:32 PM

Still no luck :S

#4 alan543

alan543
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 23 February 2006 - 09:26 AM

[!--quoteo(post=348372:date=Feb 22 2006, 11:32 AM:name=Twentyoneth)--][div class=\'quotetop\']QUOTE(Twentyoneth @ Feb 22 2006, 11:32 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Still no luck :S
[/quote]

Are you getting an error or is the mail just not sending? If it just isn't sending then it could be your php.ini setup.

#5 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 24 February 2006 - 12:57 AM

No I dont get any errors, my host has erros turned off, and I dont believe I can access the php.ini file...is there a work around?

#6 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 24 February 2006 - 01:01 AM

hmmmm.... *thinks* rite how bout u try running it locally on ur machine and then u'll know wht the errror's are.... or use error handling (althoug not sure if it will work coz u said they have blocked showing all errors )

anyway hope i helped !!

#7 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 24 February 2006 - 01:13 AM

ini_set("display_errors", "1");
ini_set("error_reporting", "E_ALL");


#8 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 24 February 2006 - 08:00 AM

I pasted that code in my php and still nothing.

#9 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 26 February 2006 - 02:00 AM

[!--quoteo(post=348956:date=Feb 24 2006, 04:00 AM:name=Twentyoneth)--][div class=\'quotetop\']QUOTE(Twentyoneth @ Feb 24 2006, 04:00 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I pasted that code in my php and still nothing.
[/quote]

....Any help? After all of this time I cant get it to work...

#10 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 26 February 2006 - 03:27 AM

Can you post the code you are currently using, exactly as it is? Can you tell us exactly what does happen, i.e. define "doesn't work" for us?

I assume that the script is saved as somename.php and that it is running on a server equipped with a mail server, not running on your computer?
Legend has it that reading the manual never killed anyone.
My site

#11 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 26 February 2006 - 03:45 AM

[!--quoteo(post=349466:date=Feb 25 2006, 11:27 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Feb 25 2006, 11:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Can you post the code you are currently using, exactly as it is? Can you tell us exactly what does happen, i.e. define "doesn't work" for us?

I assume that the script is saved as somename.php and that it is running on a server equipped with a mail server, not running on your computer?
[/quote]


email.php
<form action="submit.php" method="POST">
<b>Email:</b><br>
<input type="text" name="email_address" /><br>
<b>Subject:</b><br>
<input type="text" name="subject" /><br>
<b>Message:</b><br>
<input type="text" name="message" /><br><br>
<input type="submit" value="Submit" />
</form>

submit.php
<?php

$email_address = $_POST['email_address'];
$subject = "Subject Here";
$message = "Message Here";
    
mail($email_address, $subject, $message, "From: Your Name<......@hotmail.com>\nX-Mailer: PHP/" . phpversion());

?>

What it does, when you click submit, it sends you to "submit.php" and loads nothing but my layout. I dont get any error messages, my host has disabled it.

#12 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 27 February 2006 - 10:50 PM

No help?

#13 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 28 February 2006 - 12:02 AM

[!--quoteo(post=349469:date=Feb 25 2006, 10:45 PM:name=Twentyoneth)--][div class=\'quotetop\']QUOTE(Twentyoneth @ Feb 25 2006, 10:45 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]What it does, when you click submit, it sends you to "submit.php" and loads nothing but my layout. I dont get any error messages, my host has disabled it.[/quote]
But there isn't any layout stuff in the version of submit.php that you posted.

Try this:

#1 change your form action to point to submit2.php and save that code
#2 save exactly the code you posted above (as submit.php) as submit2.php but add the two error reporting lines from the post by hitman6003
#3 upload the revised form code and submit2.php to your server

Run the new version of the form script. If there are no errors, you should see a blank page. Check the email address you are sending this to, including the spam and/or junk folders (although using a POP3 email address usually works more reliably than a free webmail address). Let us know what happens.

Legend has it that reading the manual never killed anyone.
My site

#14 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 02 March 2006 - 11:16 PM

I didnt paste my whole layout in the submit.php nor the email.php, but they both contain the same exact layout, with different code for whats being done. I have tried sending it to gmail, hotmail, yahoo, and outlook express accounts, and I have checked them, and nothing. I have put the error message lines in the code, but I get a blank page, where the error would be.

#15 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 04 March 2006 - 09:09 PM

Again, nothing has changed, there are no errors.

#16 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 March 2006 - 10:38 PM

To enable error reporting when your host has turned if off use:
<?php
// To have all errors reported, use
ini_set('error_reporting', E_ALL);
// To have none of the errors reported(excludes major ones), use
ini_set('error_reporting', E_NONE);
?>

You may have to use the fifth parameter to the mail() function to set the "Return-path:" header to include the domainname you're sending the mail from.
<?php
$p5 = 'anyname@domainname.com';
mail($to,$subj,$msg,$headers,$p5);
?>
Many email systems will now reject email messages here the domain name in the "Return-path:" header does not match the domain name in the "From:" header.

Ken


#17 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 05 March 2006 - 01:24 AM

I tried that, it still didnt work. Is there a way to turn the mail function on if it is turned off in the .ini file, like the error messages?

#18 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 05 March 2006 - 01:44 AM

Can you change hosts? You shouldn't be having so many problems with sending email.

If you'd like, I'll send you my contact info via a PM and you send me your full scripts. I will put them on one of my domains, I will tell you the URL and you can try them there. If the email works, then it's your hosting service. If this is the case I would switch hosts.

Ken

#19 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 05 March 2006 - 01:50 AM

I cant afford to change hosts, but I think that they might have disabled it for mass emailing from websites, but Im just having my website email me.

Is it possible to do the "ini_set" thing for the mail function?

#20 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 06 March 2006 - 04:50 PM

[!--quoteo(post=351743:date=Mar 4 2006, 09:50 PM:name=Twentyoneth)--][div class=\'quotetop\']QUOTE(Twentyoneth @ Mar 4 2006, 09:50 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I cant afford to change hosts, but I think that they might have disabled it for mass emailing from websites, but Im just having my website email me.

Is it possible to do the "ini_set" thing for the mail function?
[/quote]

No?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users