Okay, you can remove the echo and die statements now, the process of inserting and updating is working as expected
Now on to e-mail.
Are you running PHP on a local server? ie: Your PC, or on a remote server?
Is it a Windows Server or Linux Server?
2a) If Windows, are you using Apache or IIS?
Do you know your SMTP information for your school’s email server?
3a) Do you know the SMTP server name/address? usually smtp.mydomain.com
3b) Do you know if a username and password are required for sending e-mail through the smtp server?
3b1) If Yes, do you know what the username and password are?
//After teacher has entered marks… $message =<<<EMAIL_MESSAGE
'Dear Student, for your information, scores for your most recent examination have been uploaded. Please visit Med Buddy to view your score. Thank you.
EMAIL_MESSAGE;
should it stay there/?
well,
1.i m running it on my localhost
2.linux server
3. nope, i don’t know the SMTP information for the schools email server… …
Yes, that top part is called HEREDOC, it allows you to build a string of output much easier than using string concatenation (Granted that first ’ shouldn’t be there).
Okay, so you are running on linux, which means you need to setup sendmail on your linux machine. What distro are you using?
okay, that is good and bad, that tells me you don’t have SELinux setup, which means I don’t have to worry about additional security trying to figure out how to get this setup on Fedora
On a side note, I’m going to split this tread again, and move this SendMail configuration process to the Server Configuration forum (where it will hopefully get more help).
lol, you got me there… i was wondering instead of configuring stuff, isnt there a way we could send mail through some free smtp, or gmail (my gmail account)??
require_once(‘…/class.phpmailer.php’); ///WHERE IS THE LOCATION FO THIS FILE?
$mail = new PHPMailer(true);
$mail->IsSMTP(); ////////////////////////SHOULD I LEAVE IT LIKE THIS??
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = “tls”; // sets the prefix to the servier
$mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = “yourusername@gmail.com”; // GMAIL username
$mail->Password = “yourpassword”; // GMAIL password
//This is the “Mail From:” field
$mail->SetFrom(‘name@yourdomain.com’, ‘First Last’);
//This is the “Mail To:” field
$mail->AddAddress(‘whoto@otherdomain.com’, ‘John Doe’);
$mail->Subject = ‘PHPMailer Test Subject via mail(), advanced’;
$mail->Body = “Hi!
Extract the download into your php script folder hiearchy, and include it in your class.phpmailer.php file
Leave the IsSMTP (especially if you plan to use gmail to send your communication).
Update the appropriate auth variables.
Run the script.
Once it sends you an e-mail, let me know and I’ll help you extract it to hide a lot of the common components so you can have a one line call to replace mail() with.
function send_email($to, $subject, $message)
{
// Paste PHP Mailer code, change
// $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); to $mail->AddAddress($to);
// $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; to $mail->Subject = $subject;
// $mail->Body = "Hi! \
\
This is my first e-mail sent through PHPMailer."; to $mail->Body = $message;
}
Then where you have mail(), you can replace the word mail with send_email
k, but there was one little thing i thought would be nice if we do it,
in this part of the php mailer code,
$mail->Subject = ‘New Scores Uploaded’; i wished to replace “New Scores” with $_POST[“subject”]… but it gave me some ugly error about “”" apostrophes and stuff, what is the right way to go about th is??