Asked  1 Year ago    Answers:  5   Viewed   11 times

I'm trying to get php mailer to work. I'm getting an error but couldn't find any info from google on it.

$mail = new phpmailer;

$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;

$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("user@theirsite.com", "User");
//$mail->AddAddress("ellen@site.com");   // name is optional
$mail->AddReplyTo("info@site.com", "Information");
$mail->WordWrap = 50;    // set word wrap
//$mail->AddAttachment("c:\temp\js-bak.sql");  // add attachments
//$mail->AddAttachment("c:/temp/11-10-00.zip");

$mail->IsHTML(true);    // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the message body";
$mail->Send(); // send message

The code above is what I'm using but when I try to run it I get the following in my browser...

Fatal error: Cannot access empty property in /the/full/path/to/phpmailer.inc.php on line 271

Here is the line it's referring to...

$header[] = sprintf("Content-Transfer-Encoding: %sn", $this->$Encoding);

If anyone can help it would be greatly appreciated! Thanks.

 Answers

1

Encoding is not a variable: $this->Encoding

Saturday, May 29, 2021
 
5

FIXED ISSUE FOR ME I fixed this issue in my windows php environment by downloading an updated root certificates file and pointing my php.ini file to it. It seems the problem was not with gmail's cert but rather with an outdated root certificate file due to windows server 2012 no longer updating this file automatically. Download cacert.pem from here: https://curl.haxx.se/docs/caextract.html. Then in php.ini use following line to point to it (assuming you have openssl.dll installed).

openssl.cafile={Path to the file on your server}cacert.pem.

That fixed it and I no longer needed to bypass SSL/TLS verification like suggested. Ultimately I need to get windows to update root certs automatically using GPO or WSUS. see https://serverfault.com/questions/541922/where-to-get-root-ca-certificates-for-windows-server-now-that-microsoft-no-longe

Thursday, April 1, 2021
 
4

First thing notice off-hand: Gmail uses TLS. Don't know if having SSL instead of TLS will make much of a difference but SSL is the predecessor to TLS.

I recommend checking out also, its phpmailer customized for using gmail. PHPGMailer

Thursday, April 1, 2021
 
iceduck
 
2

Namespace is important in soap response. Try below code:

<?php
$xml = '<?xml version = "1.0" encoding = "utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <GetListItemsResult>
                <listitems>
                    <rs:data>
                        <z:row ows_MetaInfo='128;#'/>
                    </rs:data>
                </listitems>
            </GetListItemsResult>
        </GetListItemsResponse>
    </soap:Body>
</soap:Envelope>';

$xml_element = simplexml_load_string($xml);
$name_spaces = $xml_element->getNamespaces(true);
$soap = $xml_element->children($name_spaces['soap'])
    ->Body
    ->children($name_spaces['rs'])
    ->GetListItemsResponse
    ->GetListItemsResult
    ->listitems
    ->{'rs:data'}
    ->{'z:row'}['ows_MetaInfo'][0];

echo (string) $soap;
?>
Thursday, April 1, 2021
 
Lance
 
3

If you Googled "CodeIgniter PHP 5.3" you would have found this article pretty quickly :)

http://philsturgeon.co.uk/blog/2009/12/CodeIgniter-on-PHP-5.3

To fix this, you only need to edit the main index.php for your CodeIgniter application:

if( ! ini_get('date.timezone') )
{
   date_default_timezone_set('GMT');
} 

This modification is something you will probably need to make for any CodeIgniter application running on PHP 5.3 and can easily be modified to your local timezone. There is a full list of supported timezones in the PHP manual here.

Sunday, August 1, 2021
 
mario
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :