Jump to content

mail function not working correctly


shaunmckinnon

Recommended Posts

prolly stoopid me:

here's what's happening:
wrote a simple mail script just to check the sending capabilities. mail refused to send. tried over and over again, still wouldn't send. sent to hotmail box instead of my outlook account. found it in the junk mail folder. thought "all right, maybe it's harder now."
went to a forum to see if anyone else has had this issue. found this script.
[code]<?
$mailtext = 'whatever';
$mailto = 'myemail@here.com';
$mailsubject = 'Us - Contact us enquiry';
$mailheaders .= "From: Shaun McKinnon Enquiry <myemail@here.com>\r\n";
$mailheaders .= 'MIME-Version: 1.0' . "\r\n";
$mailheaders .= 'Content-Type: multipart/mixed' . "\r\n";
$mailheaders .= " boundary=\"$mime_boundary\"";
$mailheaders .= "Reply-To: myemail@here.com\r\n";
$mailheaders .= "Return-Path: myemail@here.com\n";
if ($errormessage == ''){
mail($mailto,$mailsubject,$mailtext,$mailheaders);
exit;
}
?>[/code]
checked it, still goes to the junk mail folder and doesn't even appear in outlook. I receive crap in my outlook daily, so it's not restrictions on the server we use for the website. Is there anything anyone might know that would cause this issue?
Link to comment
Share on other sites

[!--quoteo(post=368734:date=Apr 26 2006, 12:37 AM:name=shaunmckinnon)--][div class=\'quotetop\']QUOTE(shaunmckinnon @ Apr 26 2006, 12:37 AM) [snapback]368734[/snapback][/div][div class=\'quotemain\'][!--quotec--]
prolly stoopid me:

here's what's happening:
wrote a simple mail script just to check the sending capabilities. mail refused to send. tried over and over again, still wouldn't send. sent to hotmail box instead of my outlook account. found it in the junk mail folder. thought "all right, maybe it's harder now."
went to a forum to see if anyone else has had this issue. found this script.
checked it, still goes to the junk mail folder and doesn't even appear in outlook. I receive crap in my outlook daily, so it's not restrictions on the server we use for the website. Is there anything anyone might know that would cause this issue?
[/quote]
Shaun,
Don't know what the problem is, but my advice is to download PHPMailer from sourceforge.net and use it. I spent countless hours trying to figure out these stupid mail headers - it's not worth the trouble. There is a tutorial on this site that takes you step by step through PHPMailer - took me 30 minutes to download, setup and start mailing (attachments, HTML, plain text).
Good luck
JRS
Link to comment
Share on other sites

[!--quoteo(post=368736:date=Apr 26 2006, 04:49 AM:name=JRS)--][div class=\'quotetop\']QUOTE(JRS @ Apr 26 2006, 04:49 AM) [snapback]368736[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Shaun,
Don't know what the problem is, but my advice is to download PHPMailer from sourceforge.net and use it. I spent countless hours trying to figure out these stupid mail headers - it's not worth the trouble. There is a tutorial on this site that takes you step by step through PHPMailer - took me 30 minutes to download, setup and start mailing (attachments, HTML, plain text).
Good luck
JRS
[/quote]
thanks, that's what i'll do i guess. it seems to me only last year that all you had to do was go mail($to, $subject, $body); and you were done. oh well. thank again.
Link to comment
Share on other sites

[!--quoteo(post=368738:date=Apr 26 2006, 01:01 AM:name=shaunmckinnon)--][div class=\'quotetop\']QUOTE(shaunmckinnon @ Apr 26 2006, 01:01 AM) [snapback]368738[/snapback][/div][div class=\'quotemain\'][!--quotec--]
thanks, that's what i'll do i guess. it seems to me only last year that all you had to do was go mail($to, $subject, $body); and you were done. oh well. thank again.
[/quote]

Yes, you are right. The problem is when you add the 4th parameter $headers - then everything breaks or sometimes works.
JRS
Link to comment
Share on other sites

I'm relieved to see you guys are having problems with mail as well. In every tutorial, book, article, whatever I read, they make it sound like sending mail with the 'mail()' function is the easiest thing in the world.

But I've tried and tried, and even simple code like this:
<?php

// Your email address
$email = "freshrod@freshrod.com";
// The subject
$subject = "testing";
// The message
$message = "I hope this works!";
mail($email, $subject, $message, "From: $email");
echo "The email has been sent.";

?>

just doesn't seem to work.
Link to comment
Share on other sites

[!--quoteo(post=368843:date=Apr 26 2006, 03:28 PM:name=freshrod)--][div class=\'quotetop\']QUOTE(freshrod @ Apr 26 2006, 03:28 PM) [snapback]368843[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'm relieved to see you guys are having problems with mail as well. In every tutorial, book, article, whatever I read, they make it sound like sending mail with the 'mail()' function is the easiest thing in the world.

But I've tried and tried, and even simple code like this:
<?php

// Your email address
$email = "freshrod@freshrod.com";
// The subject
$subject = "testing";
// The message
$message = "I hope this works!";
mail($email, $subject, $message, "From: $email");
echo "The email has been sent.";

?>

just doesn't seem to work.
[/quote]
Are yoy running that code on a local setup of Apache/PHP? If you are then you will need to configure PHP to use an SMTP server in order for emails to be sent! You can configure the SMTP server in php.ini file.

If you are running it off your webhost then it should work or your webhsots has disabled the use of using th mail function.
Link to comment
Share on other sites

[!--quoteo(post=368880:date=Apr 26 2006, 10:53 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 26 2006, 10:53 AM) [snapback]368880[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Are yoy running that code on a local setup of Apache/PHP? If you are then you will need to configure PHP to use an SMTP server in order for emails to be sent! You can configure the SMTP server in php.ini file.

If you are running it off your webhost then it should work or your webhsots has disabled the use of using th mail function.
[/quote]

Duh-Oh! They don't call me nOOb for nothing.

Thank you wildteen88!
Link to comment
Share on other sites

Hi!

I'm having issues with the mail function too, and I'm not sure if its me being really *really* stupid, or my system is shafted.

I have the simplest bit of code ever that is just:

[code]mail("$email", "Hello!", "This is the content of the message",
                                         "From: Webmaster<$from_email>");[/code]

I'm just running it locally at the minute, and I have configured my php.ini file so that "SMTP = localhost" and "smtp_port = 25", but I'm still gettin an error when I try to run it!!

This is the error in case it helps:
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:\Program Files\Apache Group\Apache2\htdocs\Project\mail.php on line 5

I'm totally stumped. Everythin I've read seems to say that this should work fine - its the simplest thing the mail function can do!!

Help??
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This is the error in case it helps:
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:\Program Files\Apache Group\Apache2\htdocs\Project\mail.php on line 5[/quote]
You are obviously running on a Windows box. Do you have a Mail Server running on the box. Most likely, the answer is no. That's why you're getting the error.

Ken
Link to comment
Share on other sites

In order to use the mail function you will need to point php to a local/public SMTP server, one that doesn't require a login. Usually you'll find your ISP will have one and the address is something along the lines of [b]smtp.ispname.com[/b]

YOu can setup the smtp server address in the php.ini file. Open the php.ini file for editing and find the following line:
[code]SMTP = localhost[/code]
change localhost to the smtp servers address.

Now save your php.ini anmd restart your Apache web server.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.