|
-
May 19th, 2007, 01:27 AM
#1
Thread Starter
WiggleWiggle
Errors with emailing script
this script is not sending an email to my account. here is my code:
PHP Code:
<?php
$confirmid = md5(date("Ymd"));
$recipient = "*******";
$from = "admin@*****.com";
$subject = "Account Activation";
$message = "Dear $membername: \n \n" .
"Thank you for joining RapidFriends Social Networking! We are glad you joined. We need you to Activate your account by clicking the link located below. \n\n\n" .
"<a href='confirm.php?id=$confirmid'>Confirm Account</a>\n\n" .
"Note: If link above didnt work, go to http://www.rapidfriends.com/confirm.php, and copy this code into the text box: \n" .
"Confirm Code: $confirmid";
$headers = "To: $membername <$memberemail>\n" .
"From: RapidFriends Admin <$from>\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1";
mail('$recipient', '$subject', '$message', '$headers');
if (@mail('$recipient', '$subject', '$message', '$headers')) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>
My usual boring signature: Something
-
May 19th, 2007, 07:24 AM
#2
Re: Errors with emailing script
Why are you putting variables in quotes:
mail('$recipient', '$subject', '$message', '$headers');
'$recipient' produces the string $recipient.
Simply use the variable name.
-
May 19th, 2007, 07:34 PM
#3
Re: Errors with emailing script
Sometimes checking the rules for your STMP server helps, if Adams solution doesnt help.
-
May 21st, 2007, 02:10 PM
#4
Re: Errors with emailing script
don't do this:
PHP Code:
mail('$recipient', '$subject', '$message', '$headers');
if (@mail('$recipient', '$subject', '$message', '$headers')) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
that will send the mail twice. that's not what you want. call mail() only once. either get rid of the if() statement, or get rid of the singular mail() call.
-
May 21st, 2007, 05:58 PM
#5
Re: Errors with emailing script
You can put variables in quotes e.g "my name is $name" but in this case its better without.
Anyway I don't think thats whats stopping it. I think its the To field you specify in the header, why do you need this when you have already told it where to send to in the first argument mail(TO,...)
-
May 21st, 2007, 10:01 PM
#6
Re: Errors with emailing script
SMTP headers are separated by \r\n, not \n.
-
May 21st, 2007, 10:08 PM
#7
Thread Starter
WiggleWiggle
Re: Errors with emailing script
k thanks all for you help
My usual boring signature: Something
-
May 28th, 2007, 01:09 AM
#8
Thread Starter
WiggleWiggle
Re: Errors with emailing script
ok i now have this code, copied from php.net and it doesnt work...
PHP Code:
#SEND EMAIL
// multiple recipients
$to = "$email";
// subject
$subject = 'Confirm Your RapidFriends Account';
// message
$message = "
<html>
<head>
<title>Confirm Your RapidFriends Account</title>
</head>
<body>
<p>
Dear $first, <br>
<br>
Thank you for signing up with RapidFriends Social Networking!
Before you can login, you must first confirm your account.<br>
<br>
<a href='http://www.rapidfriends.com/signup.php?step=3&confirm=$confirmcode'>Confirm Account</a><br>
<br>
If link doesnt apear above, copy and paste this URL into your browser:<br>
http://www.rapidfriends.com/signup.php?step=3&confirm=$confirmcode<br>
<br>
Thanks,<br>
RapidFriends Admin
</p>
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "To: $first $last <$email>" . "\r\n";
$headers .= 'From: RapidFriends Admin <[email protected]>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
echo "An email has been sent to $email. Please check it for your confirm link.";
i edited it for my needs
My usual boring signature: Something
-
May 28th, 2007, 03:51 AM
#9
Re: Errors with emailing script
It doesn't work doesn't really tell us much. Are you not getting an email? Are you getting any errors?
-
May 28th, 2007, 01:30 PM
#10
Thread Starter
WiggleWiggle
Re: Errors with emailing script
well me personaly am not getting the email. i have other people testing my code and they are getting the email.
My usual boring signature: Something
-
May 28th, 2007, 02:39 PM
#11
Re: Errors with emailing script
The email is probably being flagged as spam and deleted. You need to ensure the domain part of the from address resolves to the same IP address as the server you are sending it from.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|