1

Here i try to create a process to sent email from server..after i click button save/send, there always server error 500 appear..anyone cant help me fix it..

<?php
include('../include/dbconn.php');
include('PHPMailer/PHPMailerAutoload.php');
require('PHPMailer/class.PHPMailer.php');

            $to = $_POST['email_to'];
            $subject = $_POST['subject'];
            $message = $_POST['message'];
            $img = $_FILES["img"]["name"];
            $from = "info@internationaltimes.com.my";
            $cc = $_POST['email_cc'];
            $bcc = $_POST['email_bcc'];

            $headers .= "From: $from \r\n";
            $headers .= "Reply-To: $from \r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
            //SET EMAIL PRIORITY

            //$headers .= "X-Priority: 1 (Highest)\n";
            $headers .= "X-MSMail-Priority: High\n";
            $headers .= "Importance: High\n";



$add = mysql_query($conn, "INSERT INTO email_sent_inbox set sent_time = now(), sender = '$_POST[username]', mailto = '$_POST[email_to]', cc = '$_POST[email_cc]', bcc = '$_POST[email_bcc]', mail_subject = '$_POST[subject]', message = '$_POST[message]'" or die (mysql_error());

if($add){
    $retval = mail ($to,$subject,$message,$header); 
    if($retval)
    {
        echo "<script>window.location='newsletter_blasting.php';</script>"; 
    }
}
?>

2 Answers2

0

Remove all the sharedPreference stuff.

In the first activity before startActivity(intent) add this:

intent.putExtra("name", n);
intent.putExtra("id", i);
intent.putExtra("class", c);

In the second activity:

Bundle bundle = getIntent().getExtras();
String n = bundle.getString("name");
String i = bundle.getString("id");
String c = bundle.getString("class");
priyank
  • 2,651
  • 4
  • 24
  • 36
  • i need to delete this part in first activity SharedPreferences pref = getSharedPreferences("SharedPreferencesDemo",MODE_PRIVATE); Editor edit = pref.edit(); edit.putString("name", n); edit.putString("reg", i); edit.putString("class", c); edit.commit(); Intent intent = new Intent(this, SecondActivity.class); – Frankie Jones Igat Mar 29 '15 at 08:46
  • Not this line `Intent intent = new Intent(this, SecondActivity.class);` – priyank Mar 29 '15 at 08:49
  • When insert this code in secondactivity its become a error Bundle bundle = getIntent().getExtras(); String n = bundle.getExtras("name"); String i = bundle.getExtras("id"); String c = bundle.getExtras("class"); – Frankie Jones Igat Mar 29 '15 at 09:12
  • The method getExtras(String) is undefined for the type Bundle SecondActivity.java – Frankie Jones Igat Mar 29 '15 at 09:17
0

You are using two different names in getSharedPreferences()

Activity one- getSharedPreferences("SharedPreferencesDemo",MODE_PRIVATE)

Activity two- getSharedPreferences("SharedPreferences", MODE_PRIVATE);

Try giving the same name.

More info here.

Community
  • 1
  • 1
Sajith Sageer
  • 163
  • 3
  • 16