Generate Email script

Reply

Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Generate Email script

 
0
  #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?

  1. <?php
  2.  
  3. function send_mail($fromname,$frommail,$to,$subject,$body,$priority)
  4. {
  5. $fullmail = "\"$fromname\"<$frommail>";
  6. $headers = "From: $fullmail\n";
  7. $headers .= "X-Sender: $fullmail\n";
  8. $headers .= "X-Mailer: PHP\n";
  9. $headers .= "X-Priority: $priority\n";
  10. $headers .= "Return-path: $fullmail\n";
  11.  
  12. mail($to,$subject,$body,$headers);
  13. }
  14.  
  15. function send_html_mail($fromname,$frommail,$to,$subject,$body,$priority)
  16. {
  17. $fullmail = "\"$fromname\"<$frommail>";
  18. $headers = 'MIME-Version: 1.0' . "\n";
  19. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
  20. $headers .= "From: $fullmail\n";
  21. $headers .= "X-Sender: $fullmail\n";
  22. $headers .= "X-Mailer: PHP\n";
  23. $headers .= "X-Priority: $priority\n";
  24. $headers .= "Return-path: $fullmail\n";
  25.  
  26. mail($to,$subject,$body,$headers);
  27. }
  28.  
  29. ?>
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Generate Email script

 
0
  #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 Quick reply to this message  
Join Date: Feb 2002
Posts: 12,044
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 131
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Generate Email script

 
0
  #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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Re: Generate Email script

 
0
  #4
May 2nd, 2007
Well, its just not sending the email at all!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Generate Email script

 
0
  #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 Quick reply to this message  
Join Date: Sep 2005
Posts: 1,081
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Generate Email script

 
0
  #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 Quick reply to this message  
Join Date: Apr 2007
Posts: 9
Reputation: tomf is an unknown quantity at this point 
Solved Threads: 0
tomf tomf is offline Offline
Newbie Poster

Re: Generate Email script

 
0
  #7
May 3rd, 2007
Its clustered linux servers i think
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,081
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Generate Email script

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC