/    Sign up×
Community /Pin to ProfileBookmark

mail not working :(

Hi,

I am using the function below to send my mail. I am testing it but i cant quite see why it isn’t working?

Any ideas or improvements.

[code=php]
// Calling the function
$user_id = 6

SendEmail(“ActivationAdmin_Confirm”, $user_id);

// The function in the config file
// Send Email //
function SendEmail($message, $user_id) {

// Connection //
if (!($sql_id = @mysql_connect(MySQL_SERVER, MySQL_USERNAME, MySQL_PASSWORD))) {

if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_connect”, $sql_id);
}

// Activate database //

if (!@mysql_select_db(MySQL_DATABASE, $sql_id)) {

if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_select_db”, $sql_id);
}

// Query the database //

$sql_query = “SELECT * FROM “.DATABASE_PREFIX.”users WHERE Username = ‘$user_id’ LIMIT 1”;

$sql_query = (@mysql_query($sql_query, $sql_id));

if (!$sql_query) {

if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_insert”, $sql_id);
}

while ($row = mysql_fetch_array($sql_query)) {
extract($row);

switch ($message) {

case “Activation_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “Your activation number is “.$row[‘ActivationNum’].”.n”;
$msg .= “n”;
$msg .= “Please click on the link below to activate your accountn”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”?actnum=”.$row[‘ActivationNum’].”n”;
$msg .= “n”;
$msg .= “If you experieance any problems please copy and paste this link into your browser and type the activation number into the appropriate place.n”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Activation Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Activation <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;

case “ActivationAdmin_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “Your activation number is “.$row[‘ActivationNum’].”.n”;
$msg .= “n”;
$msg .= “Please click on the link below to activate your accountn”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”?actnum=”.$row[‘ActivationNum’].”n”;
$msg .= “n”;
$msg .= “After you have activated your account you must wait for a member of “.SITE_NAME.” to confirm your registration. We aim to activate your account within “.EMAIL_RESPONDT.”.n”;
$msg .= “n”;
$msg .= “If you experieance any problems please copy and paste this link into your browser and type the activation number into the appropriate place.n”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Activation Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Activation <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;

case “Admin_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “n”;
$msg .= “Your must wait for a member of “.SITE_NAME.” to confirm your registration. We aim to activate your account within “.EMAIL_RESPONDT.”.n”;
$msg .= “n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Admin Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Admin <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;

case “Registration_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “n”;
$msg .= “Your account is fully registered. Please find your details below: -n”;
$msg .= “Your Username is: – “.$row[‘Username’].”.n”;
$msg .= “n”;
$msg .= “Your password is not sent for security reasons, but if you do forget your password you can request a new one here.n”;
$msg .= “n”;
$msg .= “”.EMAIL_LOSTPASSWORD.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Admin Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Admin <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;

}

mail($recipient, $subject, $msg, $mailheaders);
}
}
[/code]

Thanks

Adam

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@k0r54authorMar 22.2005 — P.S sorry about the three posts. Please just reply to this one.

The webdev was down when i posted it it mustsa done it by mistake.

Thanks

Adam
Copy linkTweet thisAlerts:
@DARTHTAMPONMar 22.2005 — could you try and limit your problem down to 10 or 15 lines of code. You are less likly to get help when there are 200 lines because nobody wants to go through all of it. try to ax all code that is irrelevent to the problem. Then we may be able to give you a quicker answer.
Copy linkTweet thisAlerts:
@k0r54authorMar 22.2005 — sorry about that ?

[code=php]
// Calling the function
$user_id = 6

SendEmail("ActivationAdmin_Confirm", $user_id);




// The function in the config file
// Send Email //
function SendEmail($message, $user_id) {



// Query the database //

$sql_query = "SELECT * FROM ".DATABASE_PREFIX."users WHERE Username = '$user_id' LIMIT 1";

$sql_query = (@mysql_query($sql_query, $sql_id));

if (!$sql_query) {

if (SQL_SHOW_ERRORS == "true") SamePageErrorMsg("mysql_insert", $sql_id);
}

while ($row = mysql_fetch_array($sql_query)) {
extract($row);

switch ($message) {

case "Activation_Confirm":
$msg = "Hi ".$row['Salutation']." ".$row['FirstName']." ".$row['LastName']."nn";
$msg .= "** This is an automated email**n";
$msg .= "n";
$msg .= "Thank you for registering to ".SITE_NAME.".n";
$msg .= "Your activation number is ".$row['ActivationNum'].".n";
$msg .= "n";
$msg .= "Please click on the link below to activate your accountn";
$msg .= "".EMAIL_ACTIVATIONLINK."?actnum=".$row['ActivationNum']."n";
$msg .= "n";
$msg .= "If you experieance any problems please copy and paste this link into your browser and type the activation number into the appropriate place.n";
$msg .= "".EMAIL_ACTIVATIONLINK."n";
$msg .= "n".EMAIL_COPYRIGHT.""; // Copyright Link
$recipient = "".$row['Email'].""; // Recipient Address
$subject = "".SITE_NAME." Activation Confirm"; // Email Subject
$mailheaders = "From: ".SITE_NAME." Activation <[email protected]> n";
//$mailheaders = "Reply-To: $_POST[email]";
break;

}

mail($recipient, $subject, $msg, $mailheaders);
}
}

[/code]


Thanks

Adam
Copy linkTweet thisAlerts:
@96turnerriMar 22.2005 — 1) wheres the connection to the database?

2) ActivationAdmin_Confirm this is not a case in your switch statement

3) $mailheaders = "From: ".SITE_NAME." Activation <[email protected]> n"; should be $mailheaders = "From: ".SITE_NAME." Activation <[email protected]>rn";

4) just after extract($row); have you tried adding exit($row['Salutation']); to check its actually getting stuff from the db?

5) Are you getting any errors? or is it just not working
Copy linkTweet thisAlerts:
@k0r54authorMar 22.2005 — Hi,

Yes i know the adminactivation isn't coz i shrunk it for the forum which is why the connection isn't there aswell.

What does the r do?

There is no errors it just dont send the email?

Thanks

Adam
Copy linkTweet thisAlerts:
@96turnerriMar 22.2005 — so there is no difference between

Activation_Confirm and ActivationAdmin_Confirm?

r is a carriage return
Copy linkTweet thisAlerts:
@k0r54authorMar 22.2005 — Hi, i have got it working now.

The problem was that i hadn't put the function inside the else.

Anyway wat does the r do exactly.
Copy linkTweet thisAlerts:
@96turnerriMar 22.2005 — [URL=http://www.webopedia.com/TERM/c/carriage_return.html]r[/URL]
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...