Solved

I cant receive emails sent from the php script

Posted on 2006-11-15
13
229 Views
Last Modified: 2007-01-02
hi i had a php script installed on my website's contact page but i cant receive emails sent from this php script. althogh i get a message saying information sent successfully on the website but i cant find the email in my mail box anywhere.. my coding of the mail portion is as follows

 if ($send != "no") {
   
        // this is the info that comes on the email when it's ok to send!
        $msg = "E-MAIL SENT FROM http://www.yoursite.net/contact/\n";
        $msg .= "Sender's Name:    $sender_name\n";
        $msg .= "Sender's E-Mail:  $sender_email\n";
          $msg .= "Sender's  Company:  $sender_company\n";
        $msg .= "Message:          $message\n\n";    
       /* $to = "ryulite04@gmail.com";*/
        $subject = "Information";
        $mailheaders = "From: Information\n \n".
                                    "Reply-To: $sender_email\n\n".
                                    'MIME-Version: 1.0' . "\r\n".
                                    'Content-type: text/html; charset=iso-8859-1' . "\r\n";

        mail("ryulite04@gmail.com", $subject, $msg, $mailheaders);
        echo " <div align=\"center\"><table  width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    echo " <tr><td height=\"20\" colspan=2 >&nbsp;</td></tr>";
     
is there anything wrong with the way i wrote the code?
0
Comment
Question by:ryulite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
13 Comments
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 250 total points
ID: 17953094
Two things.
1.  You have, in a couple places, \n\n.  That's incorrect.  All headers in e-mail always end with \r\n (it doesn't matter what platform you're using). Inside the body of the message you're free to write anything you like, but in the headers it's always \r\n.

2.  You've got a header that reads "From: Information"  That's not a valida ddress, so I wouldn't expect your server to pass it along.

0
 

Author Comment

by:ryulite
ID: 17953143
so for the header that reads from information.. what would be the best way to write it? is it my own email address or?
0
 

Author Comment

by:ryulite
ID: 17953156
can i put From:Information as From:www.makemoneywithlynn.biz or From: $sender_email
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:ryulite
ID: 17953180
i tried From: $sender_email but no avail
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953184
The From: is the genuine From: header that will show up on the incoming mail, so it can't be just a domain name, and I'd recommend against using $sender_email for semantic reasons (though that would certainly work).  

If possible, use some account on your e-mail server that can receive mail (even if nobody's ever going to look at it) so you have the option fo doing something like bouncing back messages that come there (in case anybody replies to this e-mail).  As long as it's a legitimate-LOOKING e-mail address (that your server will recognize) you should be fine.
0
 

Author Comment

by:ryulite
ID: 17953212
i used my hotmail address but it still doesnt work.. or they cant accept free based address?
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953224
It's entirely up to how the SMTP server you're using is configured.  I've worked with some systems that blindly send on any address, and others that only accept mail from addresses on that system.  As I said, your best bet is to use an address on that system (i.e. the system that's hosting your SMTP server) that it will recognize as genuine.
0
 

Author Comment

by:ryulite
ID: 17953382
i used my teknon media's web hosting email but i cant get it to send it to my email account.
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17953399
Looking back through this I've realized you never actually said...

Does the mail() function actually return true?
0
 

Author Comment

by:ryulite
ID: 17953466
ssorry but i am a newbie to php and i don really know how to run through the code with dreamweaver
0
 
LVL 1

Assisted Solution

by:saukstas
saukstas earned 250 total points
ID: 17954003
If you want to check do this:
 $sent = mail(<everything you wrote there>)

if ($sent) {
 echo "sent ok";
} else {
 echo "sent failed"
}

your php configuration may not allow you to send emails because of missing SMTP configuration. open your php.ini file and look there for configuration value named smtp. you should write there your ISP's SMTP server's address.

Good luck ;)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question