Send an Email in PHP

Reply

Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Send an Email in PHP

 
0
  #1
Mar 5th, 2008
Hello Im looking for a real simple way, if possible with no databases involved, to send an email to a hosting account on godaddy. I believe they use smtp.secureserver.net for the smtp server. I have a form that asks for the persons name and their email..I am later going to make some sortof mailing list, So if you know of a easily integratable mailing list app let me know.

Thanks In advance for any help offered
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 9
Reputation: fert is an unknown quantity at this point 
Solved Threads: 1
fert's Avatar
fert fert is offline Offline
Newbie Poster

Re: Send an Email in PHP

 
1
  #2
Mar 5th, 2008
The chances are quite good they already configured the server for you, so you can simply send a mail.
HAve a look at this function to send an email; http://www.php.net/manual/en/function.mail.php

Example:
  1. <?php
  2. $mail['to'] = 'person@domain.suffix';
  3. $mail['from'] = 'you@' . $_SERVER['SERVER_NAME'] . '.suffix';
  4. $mail['subject'] = 'Newsletter';
  5. $mail['message'] = "Hello,\r\n\r\nHow are you?";
  6. $mail['message'] .= "\r\n\r\nUntil Later\r\nYour Team";
  7. $mail['header'] = "From: \"Your Team\" <" . $mail['from'] . ">\r\n";
  8.  
  9. $mail['status'] = @mail($mail['to'], $mail['subject'], $mail['message'], $mail['header']);
  10. if ($mail['status'] == false) {
  11. echo 'Failed to send mail to ' . $mail['to'] . '.<br>Error: ' . error_get_last();
  12. exit;
  13. }
  14. else {
  15. echo 'Sent mail to ' . $mail['to'] . ' with no errors.';
  16. continue;
  17. }
  18. ?>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: Send an Email in PHP

 
0
  #3
Mar 5th, 2008
Ah, the gdform. I tried for over a week to send mail through GoDaddy. My client had the small to medium sized business plan. I would test the code on different servers and it would work, but when I'd move it onto the GoDaddy machine, it would fail. I wound up making a page using php_info() and found that mail, along with many other functions were disabled on the server. If you haven't yet done so, create a php_info page and have a look.
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Send an Email in PHP

 
0
  #4
Mar 6th, 2008
It appears that mail is enabled from what I can tell because the phpinfo lists send_mail and smtp info. I havent tried out the code yet but I will soon.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 1,478
Reputation: mikeandike22 is an unknown quantity at this point 
Solved Threads: 18
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Send an Email in PHP

 
0
  #5
Mar 6th, 2008
That code worked perfectly thanks fert.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






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