Go Back   HostGator Peer Support Forums > General Discussion > Webhosting

Notices

Reply
 
Thread Tools
  #1  
Old 03-30-2006, 07:47 AM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Question Simple SendMail question...

Hello all,

I am used to working in with ASP, not PhP so I have a simple question...

How do I have SendMail send an email to two email addresses?

with ASP, it was a simple comma in between two emails. I tried this with PhP and it won't work. I also tried a semicolon with no luck.

If it isn't possible, can you have a default domain mail sent to two email addresses?

thanks
Reply With Quote
  #2  
Old 03-30-2006, 09:54 AM
dema dema is offline
Baby Croc
 
Join Date: Feb 2006
Location: Toledo, OH
Posts: 65
Default Re: Simple SendMail question...

If you sending mail via a PHP script, you probably just need to check out the mail() command.
Reply With Quote
  #3  
Old 03-30-2006, 10:36 AM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Default Re: Simple SendMail question...

According to that, it just needs a comma, but that didn't work
Reply With Quote
  #4  
Old 03-30-2006, 11:51 AM
dema dema is offline
Baby Croc
 
Join Date: Feb 2006
Location: Toledo, OH
Posts: 65
Default Re: Simple SendMail question...

Hm, could you post a specific example of the code that is failing for you?

Typically when I send to multiple recipients or have a more complex email I use the custome headers parameter and just do any 'To' and 'CC' headers manually, but using commas in the variable for the 'to' parameter should work.
Reply With Quote
  #5  
Old 03-30-2006, 01:08 PM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Thumbs up Re: Simple SendMail question...

Well, I got it to work

Basically, I just had to repeat the code with a second email address, such as:


mail("someone@gmail.com", $subject, $message, $from);
mail("somebody@hotmail.com", $subject, $message, $from);


Reply With Quote
  #6  
Old 03-30-2006, 04:07 PM
TeeJa's Avatar
TeeJa TeeJa is offline
Royal Croc
 
Join Date: Dec 2004
Location: Kerrville & Rockport, Texas
Posts: 709
Default Re: Simple SendMail question...

Quote:
Originally Posted by Serra
Yea, but you aren't using the -f parm. You really need to be doing that.
Yes, for sure, and if that was a real hotmail account, I got money it would bounce to....
Reply With Quote
  #7  
Old 03-31-2006, 07:28 AM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Question Re: Simple SendMail question...

What is the -f parm? (parameter?)
Reply With Quote
  #8  
Old 03-31-2006, 07:54 AM
dema dema is offline
Baby Croc
 
Join Date: Feb 2006
Location: Toledo, OH
Posts: 65
Default Re: Simple SendMail question...

"$RAND_USER says use $RAND_PARAM!"

Check out the mail() doc page and scroll down to additional_parameters (optional) subheader under the Parameters header.

Here's an explination from the sendmail() man page:
Quote:
-fname Sets the name of the ``from'' person (i.e., the envelope sender
of the mail). This address may also be used in the From: header
if that header is missing during initial submission. The enve-
lope sender address is used as the recipient for delivery status
notifications and may also appear in a Return-Path: header. -f
should only be used by ``trusted'' users (normally root, daemon,
and network) or if the person you are trying to become is the
same as the person you are. Otherwise, an X-Authentication-
Warning header will be added to the message.
There's also a more practical note about the option in the comments:
Quote:
If you're using a linux server using Postfix, and your server hasn't the host name set to a valid name (because it's behind a firewall in an intranet), it's possible that when sending mails using the mail function, some mail servers reject them. This is because they can't check the return path header. If you want to change the Return-Path used by sendmail init the php.ini and edit the sendmail_path variable to this:

sendmail_path = "sendmail -t -i -F webmaster@yoursite.com -f webmaster@yoursite.com"
Reply With Quote
  #9  
Old 03-31-2006, 10:15 AM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Default Re: Simple SendMail question...

So, are you saying that the -f is the from? And that I should have a default from address?

The code I am using is grabbing the from address from the form. Here is the code for sending the form:


<?php
if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($name) || empty($email) || empty($phone) || empty($comments )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;
$todayis = date("l, F j, Y, g:i a") ;

$subject == 'Contact Form';
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: whoever \n
Message: $comments \n
From: $name ($email)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $email\r\n";

mail("somebody@gmail.com", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $name ?> ( <?php echo $email ?> )
<br />
Attention: whoever
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $comments);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
</p>
Reply With Quote
  #10  
Old 03-31-2006, 11:46 AM
TeeJa's Avatar
TeeJa TeeJa is offline
Royal Croc
 
Join Date: Dec 2004
Location: Kerrville & Rockport, Texas
Posts: 709
Default Re: Simple SendMail question...

This is how I do it, change your variable to suit.

Code:
$f="-f";
$returnpath = "webmaster@yourserver.com";

mail("somebody@gmail.com", $subject, $message, "$f$returnpath");
Now gives me a return path that most will accept.
Reply With Quote
  #11  
Old 03-31-2006, 11:54 AM
Weizguy's Avatar
Weizguy Weizguy is offline
Hatchling Croc
 
Join Date: Mar 2006
Posts: 13
Default Re: Simple SendMail question...

OK, now my question is, if I am receiving the emails without the -f parm, why else would I need it?
Reply With Quote
  #12  
Old 03-31-2006, 04:24 PM
TeeJa's Avatar
TeeJa TeeJa is offline
Royal Croc
 
Join Date: Dec 2004
Location: Kerrville & Rockport, Texas
Posts: 709
Default Re: Simple SendMail question...

Quote:
Originally Posted by Serra
If you are the only person who is getting mails from the form, then you don't.
Unless his email addy is yahoo, hotmail, aol???
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 05:21 AM.