/    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

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMar 22.2005 — when you use mysql_fetch_array() or a similar function, set the second parameter, by default mysql_fetch_array() return results using MYSQL_BOTH, ex. mysql_fetch_array($result, MYSQL_ASSOC)
Copy linkTweet thisAlerts:
@k0r54authorMar 22.2005 — sorry that went right over my head
Copy linkTweet thisAlerts:
@ShrineDesignsMar 22.2005 — exampleSELECT COUNT(*) AS <span><code>count</code></span> FROM <span><code>table</code></span>
MYSQL_BOTH would returnArray
(
0 =&gt; 10,
'count' =&gt; 10
)
MYSQL_ASSOC would returnArray
(
'count' =&gt; 10
)
MYSQL_NUM would returnArray
(
0 =&gt; 10
)
×

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.18,
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,
)...