News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Add REST API

Started by Finaddicts, October 09, 2013, 07:56:27 PM

Previous topic - Next topic

Finaddicts

Let me start off by saying I'm not a developer so this gets confusing for me. I need to add a REST API for email notifications for activations, PM's and post. Here's my situation, I have been searching a couple of forums to try and understand the process. I was using PHP mail for the notifications but they were delayed by days so I switched to SMTP mail. My host is GoDaddy so I'm limited to 250 relays a day or purchase more relays. GoDaddy does have their SMTP relay using hxxp:email-hosting.secureserver.net [nonactive] but that is delayed as well. I ended up purchasing Elastic Email SMTP relay but GoDaddy doesn't allow 3rd party SMTP from their servers. Does anyone know how I would go about adding the Elastic Email REST API to the SMF forums. If it isn't too hard I would like to try.


Thanks in advance....

margarett

SMF 2.x has a built in mail queue (IIRC,  per hour, not per day)

Will it suit your needs?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Finaddicts

I have the built in queue working but once I hit 250 for the day the email will stay in queue until the next day when we get another 250 allotment.

margarett

Can I ask you how much did that "Elastic" software costed to you?

My advice to you: change host. I don't see anyone wanting to develop an API for that.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

Actually it shouldn't be *that* difficult: it would just be a matter of POST some data to an url instead of format the message and pass it to mail smtp_mail.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Finaddicts

Elastic is about 8.00 a month for 10k relays, the longer you stay with them it drops to 7.20 a month.  They have the sample coding that could be modified and used, I have no idea where I would go to install it.

emanuele

DISCLAIMER: untested (since I don't have an account there) and the probability it doesn't work is very, very high. ;)

In Subs-Post.php:
Code (find) Select

// Sending HTML?  Let's plop in some basic stuff, then.
if ($send_html)

Code (replace with) Select
$modSettings['elasticmail_url'] = 'https://api.elasticemail.com/mailer/send';
$modSettings['elasticmail_user'] = '';
$modSettings['elasticmail_key'] = '';

if (!empty($modSettings['elasticmail_user']) && !empty($modSettings['elasticmail_key']))
{
global $sourcedir;

$post_data = array(
'username' => $modSettings['elasticmail_user'],
'api_key' => $modSettings['elasticmail_key'],
'from_name' => $from_name,
'from' => empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'],
'to' => implode(';', $to_array),
'subject' => $subject,
'encodingtype' => 1 // <= 7bit...I *think*
);
if ($send_html)
$post_data['body_html'] = $message;
else
$post_data['body_text'] = $message;
if ($from !== null)
$post_data['reply_to'] = $from;

require_once($sourcedir . '/Subs-Package.php');
$posted_data = '';
foreach ($post_data as $key => $val)
$posted_data .= (empty($posted_data) ? '' : '&') . $key . '=' . urlencode($val);
$el_resp = fetch_web_data($modSettings['elasticmail_url'], $posted_data);
}
// Sending HTML?  Let's plop in some basic stuff, then.
elseif ($send_html)


Put your user and account in the two variables up there like this:
$modSettings['elasticmail_user'] = 'username here';
$modSettings['elasticmail_key'] = 'api key here';

And cross your fingers. :P
I'd try it on a test forum first. ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Finaddicts

Quote from: emanuele on October 10, 2013, 03:56:45 PM
DISCLAIMER: untested (since I don't have an account there) and the probability it doesn't work is very, very high. ;)

In Subs-Post.php:
Code (find) Select

// Sending HTML?  Let's plop in some basic stuff, then.
if ($send_html)

Code (replace with) Select
$modSettings['elasticmail_url'] = 'https://api.elasticemail.com/mailer/send';
$modSettings['elasticmail_user'] = '';
$modSettings['elasticmail_key'] = '';

if (!empty($modSettings['elasticmail_user']) && !empty($modSettings['elasticmail_key']))
{
global $sourcedir;

$post_data = array(
'username' => $modSettings['elasticmail_user'],
'api_key' => $modSettings['elasticmail_key'],
'from_name' => $from_name,
'from' => empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'],
'to' => implode(';', $to_array),
'subject' => $subject,
'encodingtype' => 1 // <= 7bit...I *think*
);
if ($send_html)
$post_data['body_html'] = $message;
else
$post_data['body_text'] = $message;
if ($from !== null)
$post_data['reply_to'] = $from;

require_once($sourcedir . '/Subs-Package.php');
$posted_data = '';
foreach ($post_data as $key => $val)
$posted_data .= (empty($posted_data) ? '' : '&') . $key . '=' . urlencode($val);
$el_resp = fetch_web_data($modSettings['elasticmail_url'], $posted_data);
}
// Sending HTML?  Let's plop in some basic stuff, then.
elseif ($send_html)


Put your user and account in the two variables up there like this:
$modSettings['elasticmail_user'] = 'username here';
$modSettings['elasticmail_key'] = 'api key here';

And cross your fingers. :P
I'd try it on a test forum first. ;)

I'll give it a shot....Thank you very much....

Finaddicts

Wow, just added this to a test forum and it worked......Big Thanks

margarett

Quote from: margarett on October 10, 2013, 02:14:09 AM
I don't see anyone wanting to develop an API for that.
* margarett slaps itself in the face :P

Thanks ema ;)

Marked as solved. Feel free to unmark it if you need ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

Cool! :D
Now it would be nice to pack it as mod... O:-)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Finaddicts

Just FYI, You do need to go into your hosts DNS settings and add the SPF, DKIM, and CNAME settings for this to work correctly.

dougiefresh

Topic was continued here....  along with a mod link...

Advertisement: