cfructose
02-22-2007, 09:17 PM
I'm trying to implement a php "send to friend" form that I found online, but the emails are not getting sent...
There's one other post in this forum about the very same script, and that guy had the same problem, but it turned out that his problem was related to the eail address he had been using to test the form. (The code is by BigLickMedia.com, BTW - their 'recommend site' code)
I reckon the problem has nothing to do with the code, but some Host Provider setting I'm unaware of.
In the config part of the code, I set the variable $webmasterEmail to a new email address I just created for my domain especialy to handle the 'Send To Friend' stuff, which is diverted to a gmail account. Am I being naive in thinking that the new email address should work immediately, or does it take a few hours/days for it to be 'active'?
I haven't set any spam filter yet, so that's not the problem.
Not knowing much about php (or web hosting in general!), I was wondering if there's some obvious 'setting' (for want of a better word - forgive my ignorance) that the online code neglected to mention I should 'set' with my host provider (Infinology.com). Some cgi-bin thing, php.ini, or some 'permission'...? I'm floundering here! :-)
I ask this vaguely in the hope that there is something obvious. Well, anyway, despite being 99% sure that there's nothing wrong with the code, here is the critical part, just in case:
if(empty($errormessages)) {
$emailsubject = str_replace('[name]', $_POST['name'], $emailsubject);
$emailsubject = str_replace('[email]', $_POST['email'], $emailsubject);
$emailmessage = str_replace('[name]', $_POST['name'], $emailmessage);
$emailmessage = str_replace('[url]', $url, $emailmessage);
$emailmessage .= "\r\n\n" .
$_POST['message'] .
"\n\n\n\nBlah blah.";
$emailheader = "From: " . $_POST['email'] . "\r\n" .
"Reply-To: " . $_POST['email'] . "\r\n";
$sent = array();
foreach($_POST['to'] as $key=>$value) {
if(mail($value, $emailsubject, $emailmessage, $emailheader)) {
$sent[] = $value;
}
}
$failed = array_diff($_POST['to'], $sent);
$mailsent = true;
if($receiveNotifications) {
$subject = 'Someone recommended your site';
$message = 'This is a message to tell you that ' . $_POST['name'] . ' (' . $_POST['email'] .')' .
' sent a website recommendation to ' . implode(', ', $sent) .
"\n\nMessage: " . $_POST['message'];
$headers = 'From: ' . $webmasterEmail . "\r\n" .
'send-to-friend service for mathesonbayley.com';
@mail($webmasterEmail, $subject, $message, $headers);
}
Sorry if 'php' is not the right place for this quesiton - but I figured that the host 'setting' I might be looking for probably has something to do with php.
Thanks a lot for any guidance.
There's one other post in this forum about the very same script, and that guy had the same problem, but it turned out that his problem was related to the eail address he had been using to test the form. (The code is by BigLickMedia.com, BTW - their 'recommend site' code)
I reckon the problem has nothing to do with the code, but some Host Provider setting I'm unaware of.
In the config part of the code, I set the variable $webmasterEmail to a new email address I just created for my domain especialy to handle the 'Send To Friend' stuff, which is diverted to a gmail account. Am I being naive in thinking that the new email address should work immediately, or does it take a few hours/days for it to be 'active'?
I haven't set any spam filter yet, so that's not the problem.
Not knowing much about php (or web hosting in general!), I was wondering if there's some obvious 'setting' (for want of a better word - forgive my ignorance) that the online code neglected to mention I should 'set' with my host provider (Infinology.com). Some cgi-bin thing, php.ini, or some 'permission'...? I'm floundering here! :-)
I ask this vaguely in the hope that there is something obvious. Well, anyway, despite being 99% sure that there's nothing wrong with the code, here is the critical part, just in case:
if(empty($errormessages)) {
$emailsubject = str_replace('[name]', $_POST['name'], $emailsubject);
$emailsubject = str_replace('[email]', $_POST['email'], $emailsubject);
$emailmessage = str_replace('[name]', $_POST['name'], $emailmessage);
$emailmessage = str_replace('[url]', $url, $emailmessage);
$emailmessage .= "\r\n\n" .
$_POST['message'] .
"\n\n\n\nBlah blah.";
$emailheader = "From: " . $_POST['email'] . "\r\n" .
"Reply-To: " . $_POST['email'] . "\r\n";
$sent = array();
foreach($_POST['to'] as $key=>$value) {
if(mail($value, $emailsubject, $emailmessage, $emailheader)) {
$sent[] = $value;
}
}
$failed = array_diff($_POST['to'], $sent);
$mailsent = true;
if($receiveNotifications) {
$subject = 'Someone recommended your site';
$message = 'This is a message to tell you that ' . $_POST['name'] . ' (' . $_POST['email'] .')' .
' sent a website recommendation to ' . implode(', ', $sent) .
"\n\nMessage: " . $_POST['message'];
$headers = 'From: ' . $webmasterEmail . "\r\n" .
'send-to-friend service for mathesonbayley.com';
@mail($webmasterEmail, $subject, $message, $headers);
}
Sorry if 'php' is not the right place for this quesiton - but I figured that the host 'setting' I might be looking for probably has something to do with php.
Thanks a lot for any guidance.