Jump to content

FalsAlarm

Members
  • Posts

    21
  • Joined

  • Last visited

FalsAlarm's Achievements

Member

Member (2/5)

0

Reputation

  1. I just tried using phpmailer for sending emails with smtp and gmail. below is my config file. public function SendEmailToUser($email, $subject, $message, $plainTextMessage) { //require_once './includes/mailer/class.phpmailer.php'; /** * This example shows settings to use when sending via Google's Gmail servers. */ //SMTP needs accurate times, and the PHP time zone MUST be set //This should be done in your php.ini, but this is how to do it if you don't have access to that date_default_timezone_set('Etc/UTC'); //require '../PHPMailerAutoload.php'; require_once("./includes/mailer/PHPMailerAutoload.php"); //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP //$mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = 'smtp.gmail.com'; // use // $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6 //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->Port = 587; $mail->isHTML = false; //Set the encryption system to use - ssl (deprecated) or tls //$mail->SMTPSecure = 'tls'; $mail->SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = "myEmail@gmail.com"; //Password to use for SMTP authentication $mail->Password = "myAccountPassword"; //Set who the message is to be sent from $mail->setFrom('canadeals@gmail.com', 'Ricky Mossip'); //Set an alternative reply-to address $mail->addReplyTo('canadeals@sasktel.net', 'Ricky Mossip'); //Set who the message is to be sent to $mail->addAddress($email, 'First Nation Circle Member'); //Set the subject line $mail->Subject = $subject; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML($message); //Replace the plain text body with one created manually $mail->AltBody = $message; //Attach an image file //$mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { echo "<p>Mailer Error: " . $mail->ErrorInfo . "</p>"; } else { echo "<h2>Message sent!</h2>"; } } However I just discovered the following blog, https://lecturesnippets.com/lesson/sending-email-through-the-centos-7-php-web-server/ and after following that guide i still cannot send emails using the command line or phpmailer. i tried removing the call to isSMTP(); that seems to get it to work.(it says no errors and email sent), but nothing when i check my emails and even my spam folder shows nothing.
  2. Issue Resolved. The problem is that since I was POSTING the data to php, i needed to Base64 encode the byte array before hand inside my Actionscript 3. Then on the receiving end php file, I needed to Base64_decode($byte_array) which works perfectly, the Drawing is sent from my flash GUI to the server backend and it works!!! thanks to everyone that posted
  3. Doesn't PHP have any PNG functions for working with bitmap data or anything like that?
  4. Alright, I tried your idea. Below is a PHP object that I wrote to handle the SaveImage feature of my Flash application. <code> <?php error_reporting(E_ALL); ini_set('display_errors','On'); $newUser = new SaveImage(); class SaveImage { //a reference to thd facebook object public $facebook; //holds the app users uid public $id; //holds the selected users uid public $targetUID; //the byte array data public $byteArray; //holds a reference to the db connection public $connection; //the output that gets returned to flash public $outputObject; public function __construct() { //include the database connection include 'database.php'; //include the php sdk //include the facebook sdk library require_once('facebook.php'); //instantiate a new Facebook Object, you must replace your APP_ID with your real apps app id. do the same for the secret. $this->facebook = new Facebook(array( 'appId' => 'removed', 'secret' => 'removed', 'cookie' => true)); //store a reference to the db connection in this object $this->connection = $connection; //initialize the outputObject $this->outputObject = new stdClass(); //attempt to get the current user $this->id = mysqli_real_escape_string($this->connection, $this->facebook->getUser()); $this->byteArray = $this->getByteArray(); $this->targetUID = $this->getTargetUID(); if($this->targetUID != NULL) { //continue if(isset($this->byteArray)) { //create a filepatch where to put the file. $filename = "wallImages/" . $this->targetUID . "_wallImage.png"; //use file put contents to put the file $result = file_put_contents($filename, $this->byteArray); $this->outputObject->result = "Sucess!"; } } echo json_encode($this->outputObject); } public function getByteArray() { return $_POST['byte_array']; } public function getTargetUID() { if(strlen($_POST['selectedWall']) > 0) { return mysqli_real_escape_string($this->connection, $_POST['selectedWall']); } else { return NULL; } } } ?> </code> It's kind of odd, but i'm getting the final output PNG file created, but it's only 1kb in size and doesn't open up in any image editors. It says the data might be corrupted when I try to open it.
  5. It could be a linux file permissions issue
  6. Hello I have a flash actionscript 3 project that creates a PNG image out of any Flash MovieClip. inside my as3 code i have this code which creates a successful POST to my php script. My question is how do I take the byte array variable and write it to the filesystem as a PNG image. //prepare data to send to php var bitmapData:BitmapData = graffitiGalore.drawingTab.main.canvas.drawing(true); var byteArray:ByteArray = PNGEncoder.encode(bitmapData); //create a parameters object var parametersObject:Object = new Object(); //create a POST variable to be sent to php parametersObject.byte_array = byteArray; //create a new PHPRequest and pass in the parametersObject var phpRequest:PHPRequest = new PHPRequest(); phpRequest.makeRequest(ApplicationConstants.SAVE_IMAGE, parametersObject); phpRequest.addEventListener(Event.COMPLETE, onCompleteSaveImage); ); Ok, so in php i'll have access to $_POST['byte_array'] variable which contains the PNG image byte array as data. How do I take this data and write a real PNG image to the filesystem? I'm new to lots of php stuff still.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.