Steve Davies
posted this on August 02, 2011 11:05
I am *trying* to integrate SendGrid into an existing system to take over the bulk-delivery of newsletter emails. We have our own SMTP server, but I'm switching to SendGrid (just for bulk emails) to enhance deliverability. We use PHPList on the front end to run the email campaigns and intend tto use SendGrid API to connect it as the SMTP server.
Following the instructions on my account Developer dashboard I took the following;
Comments
Here's the solution for anyone else who experiences a similar issue with integrating PHPList and SendGrid:
1. In File: /lists/config/config.php at around line 670 REPLACE the code at this point with the following;
define ("TEST",0);
define("PHPMAILERHOST",'smtp.sendgrid.net');
$phpmailer_smtpuser = '<include your SendGrid account username>';
$phpmailer_smtppassword = '<include your SendGrid account password>';
$phpmailer_smtpsecure = 'ssl'; //ssl or tls or blank
$phpmailer_smtpport = '465';
2. In File: /lists/admin/class.phplistmailer.php at around line 60..
REPLACE:
$this->Helo = getConfig("website");
$this->Host = PHPMAILERHOST;
if ( isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != ''
&& isset($GLOBALS['phpmailer_smtppassword']) && $GLOBALS['phpmailer_smtppassword']) {
add $this->SMTPAuth = true;
$this->Username = $GLOBALS['phpmailer_smtpuser'];
$this->Password = $GLOBALS['phpmailer_smtppassword'];
}
WITH:
$this->SMTPAuth = true;
//$this->Helo = getConfig("website");
$this->Host = PHPMAILERHOST;
$this->Username = $GLOBALS['phpmailer_smtpuser'];
$this->Password = $GLOBALS['phpmailer_smtppassword'];
$this->SMTPSecure = $GLOBALS['phpmailer_smtpsecure'];
$this->Port = $GLOBALS['phpmailer_smtpport'];
3. In File: /lists/admin/phpmailer/class.smtp.php at around line 105..
REPLACE:
$this->smtp_conn = fsockopen($host, # the host of the server
WITH:
$this->smtp_conn = fsockopen($host='ssl://smtp.sendgrid.net',
Thank you. This worked well, although the line numbers are way off in the current version. Great work running this down.
Ok, is it work to send using Sendgrid Email Credits or Sendgrid Newsletter Credits?
I was wondering it anyone was able to get PHPList to work with SMTPAPI? Basically instead of sending 1 email at a time (uses heaps of server resources) with SMTP use SMTPAPI to send to 1000 email blocks. Basically instead of send 1 email a thousand times send it once so similar to BCC a thousand emails.
Nic: This uses Sendgrid Email Credits.
Hi all
I've tried using the above settings but i am having no luck. Is anyone using 1and1 hosting, not sure if its a block on their ports. If the connection fails does phplist revert back to hosted smtp?
Hi Adam,
Did you follow Steve Davies comment or the original post. The comment method worked for me. If you are doing that try other ports besides 465. The list is at http://sendgrid.com/docs/User_Guide/smtp_ports.html . have to change $phpmailer_smtpsecure = 'ssl'; to $phpmailer_smtpsecure = 'tls';
Cheers
Tim
<a href="http://www.biostim.com.au/">BioStim</a>
Hi Tim
thanks for your reply
I found out that 1and1 wouldnt allow outgoing smtp connections and they have blocked 25,487 and so on.
I've not moved the hosting to just host as they do allow the connection but i still cant get it to work. The emails still show in the header they are coming from the hosting company. I've changed the settings but there must still be something telling phplist to use the host smtp!
If connection fails to external smtp does the host smtp takeover?
thanks
You are right if it breaks out of the above code (external smtp) it will use local server. The above works on Hostgator but they have limits on size of list and sending speed.
Options I can see is try to change the above to use the Sendgrid Web API to get around the blocked ports. I am trying to get SMTP API to work without much luck as it breaks out to uses server smtp.
Upgrade to higher level and use Sendgrids Newsletter app so you can drop PHPlist totally. Not practical for me as I don't send that many emails.