User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,144 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,140 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1480 | Replies: 7
Reply
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Generate Email script

  #1  
May 2nd, 2007
How can i make this script work?
It is meant to send an email to a person with a confirmation code, but it is not working. whats wrong with it?

 <?php

 function send_mail($fromname,$frommail,$to,$subject,$body,$priority)
  {
    $fullmail = "\"$fromname\"<$frommail>";
    $headers  = "From: $fullmail\n";
    $headers .= "X-Sender: $fullmail\n";
    $headers .= "X-Mailer: PHP\n";
    $headers .= "X-Priority: $priority\n";
    $headers .= "Return-path: $fullmail\n";

    mail($to,$subject,$body,$headers);
  }

 function send_html_mail($fromname,$frommail,$to,$subject,$body,$priority)
  {
    $fullmail = "\"$fromname\"<$frommail>";
    $headers  = 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
    $headers .= "From: $fullmail\n";
    $headers .= "X-Sender: $fullmail\n";
    $headers .= "X-Mailer: PHP\n";
    $headers .= "X-Priority: $priority\n";
    $headers .= "Return-path: $fullmail\n";

    mail($to,$subject,$body,$headers);
  }

?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
Staff Writer
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Generate Email script

  #2  
May 2nd, 2007
What kind of error are you getting? The odds are the problem lies somewhere else in the code.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,879
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 106
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Generate Email script

  #3  
May 2nd, 2007
We can't debug unless we know what the problem is The format for the output should be headers, then a single blank line, and then the message.
Reply With Quote  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Re: Generate Email script

  #4  
May 2nd, 2007
Well, its just not sending the email at all!
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
Staff Writer
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Generate Email script

  #5  
May 2nd, 2007
You'll need to echo out some variables in your script to make sure you have the right information there and to make sure you are getting there at all.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Sep 2005
Posts: 631
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: Generate Email script

  #6  
May 3rd, 2007
What OS is your server on?

Windows requires an SMTP server.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Re: Generate Email script

  #7  
May 3rd, 2007
Its clustered linux servers i think
Reply With Quote  
Join Date: Sep 2005
Posts: 631
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Help Re: Generate Email script

  #8  
May 3rd, 2007
Originally Posted by tomf View Post
Its clustered linux servers i think


Check first with your hosting company support and see if they have mail() set up properly. If they either you have a problem with your code or your mail may be blocked or added to spam.

You'll need to place some debugging into your code.

for starters:

[PHP]if (!mail(....)) {
echo 'Mail is not working... ';
}[/PHP]

mail() will return Boolean true or false if working or not respectively.

Set your error reporting to max:

[PHP]error_reporting(E_ALL);

ini_set('display_errors', 'true'); // not sure bout this one, I think thats the correct config option[/PHP]

Just try a simple mail() first.. don't use the abstraction function "send_mail".. just to test if its working.

Check if your hosting company's mail servers are not blacklisted.
Send emails to a few different addresses to make sure its not specific to an email address...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC