Page 1 of 1
@mail help
Posted: Thu Jan 24, 2008 11:49 am
by cdnmama
I am using a tell a friend script and wondered if anyone has a solution for me. The script will send up to 3 email addresses. When the email is received, the 3 email addresses show in the TO: field. Is it possible to alter the script so the addresses do not show, but are added to the BCC: field instead?
This is the current code....
Code: Select all
@mail("$_POST[fmail1],$_POST[fmail2],$_POST[fmail3]", $tsubject, $ttext, "FROM: $_POST[email]");
Someone suggested this, but it gives a syntax error....
Code: Select all
@mail(”", $tsubject, $ttext, “FROM: $_POST[email]”, “Bcc: $_POST[friendmail1],$_POST[friendmail2],$_POST[friendmail3]”);
Thanks for any help 
Deb
Re: @mail help
Posted: Thu Jan 24, 2008 2:18 pm
by Oren
Re: @mail help
Posted: Thu Jan 24, 2008 2:28 pm
by Kieran Huggins
are you coding in Word or something? I ask because the quotes from the example are "fancy quotes" rather than the normal kind. That would certainly mess up the parsing.
Also: swift++, but it might be a bit of a learning curve for you. I'd stick with the example your friend sent, but retype it in a proper editor to get rid of all the odd characters.
Re: @mail help
Posted: Thu Jan 24, 2008 5:53 pm
by Jonah Bron
Just stick with mail() until you get really good at php.
Use nodepad for editing php, if on win.
this is what you are looking for:
Code: Select all
mail($_POST[fmail1] .', '. $_POST[fmail2] .', '. $_POST[fmail3], $tsubject, $ttext, 'FROM: '. $_POST[email]) or die('couldn\'t sent mail');
Re: @mail help
Posted: Thu Jan 24, 2008 6:27 pm
by Chris Corbyn
PHPyoungster wrote:Just stick with mail() until you get really good at php.
Use nodepad for editing php, if on win.
this is what you are looking for:
Code: Select all
mail($_POST[fmail1] .', '. $_POST[fmail2] .', '. $_POST[fmail3], $tsubject, $ttext, 'FROM: '. $_POST[email]) or die('couldn\'t sent mail');
That will throw warnings since your array keys are not in strings.
Code: Select all
mail($_POST['fmail1'] .', '. $_POST['fmail2'] .', '. $_POST['fmail3'], $tsubject, $ttext, 'FROM: '. $_POST['email']) or die('couldn\'t sent mail');
However, I'd strongly discourage putting $_POST data right into mail() like that since this is a known way to inject headers into emails and subsequently, a perfect way for evil spammers to send spam to the masses via your server.
http://www.securephpwiki.com/index.php/Email_Injection
http://phpsense.com/php/php-mail.html
Re: @mail help
Posted: Thu Jan 24, 2008 11:57 pm
by cdnmama
Kieran Huggins wrote:are you coding in Word or something? I ask because the quotes from the example are "fancy quotes" rather than the normal kind. That would certainly mess up the parsing.
I don't write PHP code but I do copy and paste it into Notepad. I did not notice the "fancy quotes" in Notepad as the font was so small. I changed it to the proper quotes....
Code: Select all
@mail("", $tsubject, $ttext, "FROM: $_POST[email]", "Bcc: $_POST[friendmail1],$_POST[friendmail2],$_POST[friendmail3]");
I don't get the syntax error anymore, I receive the emails but the email addresses are still in the TO: field. I took a chance and altered the code to....
Code: Select all
@mail("", $tsubject, $ttext, "FROM: $_POST[email]", "Bcc: $_POST[friendmail1],Bcc: $_POST[friendmail2],Bcc: $_POST[friendmail3]");
same thing happened.
Thanks Chris....I've looked at both of these pages as well as your Swift Mailer. I downloaded and looked at the zipfile. After reading some of the wikidocs on your site, it seems quite complicated to me. What I'm looking for is a tell a friend script that allows for referral urls and will send the page to more than one email address at a time. I will read more about Swift Mailer and give it a try soon.
Deb
Re: @mail help
Posted: Fri Jan 25, 2008 12:35 am
by Chris Corbyn
Yup, that's fair enough

At the very least check that those email addresses posted contain "@" signs and don't contain any newlines.
Code: Select all
foreach (array('email', 'friendemail1', 'friendemail2', 'friendemail3') as $key) {
$address = $_POST[$key];
if (!strpos($address, '@')) {
//not a valid email address
} elseif (false !== strpos($address, "\n") || false !== strpos($address, "\r")) {
//not a valid email address
}
}
Re: @mail help
Posted: Fri Jan 25, 2008 9:43 am
by cdnmama
Chris Corbyn wrote:Yup, that's fair enough

At the very least check that those email addresses posted contain "@" signs and don't contain any newlines.
Do you mean make sure that the email addresses posted into the form have the @ sign?
What should I do with the code from your last post?
Deb