Laravel: View not included in email content - email

I am using the BeautyMail package to send an email, which is sent successfully via stmp.gmail.com. I found out that the content of emails.welcome (welcome.blade.php) is not included, the email delivered is empty.
Below is my code;
$data = array(
'LastName' => 'ABC Widget', // Company name
'senderName' => 'ABC Widget', // Company name
'reminder' => 'You’re receiving this because you’re an awesome ABC Widgets customer or subscribed via our site',
'unsubscribe' => null,
'address' => '87 Street Avenue, California, USA',
'twitter' => 'http://www.facebook.com/abcwidgets',
'facebook' => 'http://twitter.com/abcwidgets',
'flickr' => 'http://www.flickr.com/photos/abcwidgets'
);
Mail::send('emails.welcome', $data, function($message)
{
$message->from( 'johnny#gmail.com', 'John Doe' );
$message->to('Suzanne#yahoo.com', 'Suzanne Doe')->subject('Testing Messages');
});
VIEW
#extends('beautymail::templates.widgets')
#section('content')
#include('beautymail::templates.widgets.articleStart')
<h4 class="secondary"><strong>Hello World</strong></h4>
<p>This is a test</p>
#include('beautymail::templates.widgets.articleEnd')
#include('beautymail::templates.widgets.newfeatureStart')
<h4 class="secondary"><strong>Hello World again</strong></h4>
<p>This is another test</p>
#include('beautymail::templates.widgets.newfeatureEnd')
#stop
No error was reported. What I am doing wrong?

Trying removing the BeautyMail package and testing it. When I tried using the BeautyMail package, I had a similar problem.

Beautymail have Ruby dependencies. I do think one of them fails which renders the empty email.
This issue has more details:
https://github.com/Snowfire/Beautymail/issues/2
Remove the inliner found in the service provider to remove the ruby dep.

Related

Perl using USAePay billing module

I was wondering if anybody has experience using the USAePay billing module? I have reached out to the developer and his response was he does not have time to help people. My problem is this -
I have written the following code to add a customer's billing information using the Sandbox server but it looks as though the module defaults to the production server so each time I attempt to validate the transaction I get the response -
Card was rejected: Specified source key not found.
How do I tell it to use the Sandbox server?
use strict;
use warnings;
use Business::OnlinePayment;
use constant {
LOGIN => 'source key', #USAePay source key
PASSWORD => '12345', #USAePay PIN
};
my $tx = new Business::OnlinePayment("USAePay");
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
if($tx->is_success()) {
print 'Card processed successfully: '.$tx->authorization.'\n';
} else {
print 'Card was rejected: '.$tx->error_message."\n";
}
As Business::OnlinePayment::USAePay is a processor for Business::OnlinePayment, but doesn't have a lot of docs itself, a look at the docs of Business::OnlinePayment might help. It reveales the test_transaction method.
Most processors provide a test mode, where submitted transactions will not actually be charged or added to your batch, calling this function with a true argument will turn that mode on if the processor supports it, or generate a fatal error if the processor does not support a test mode (which is probably better than accidentally making real charges).
An untested example:
my $tx = new Business::OnlinePayment("USAePay");
$tx->test_transaction; # here
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
Digging a bit deeper in the source of Business::OnlinePayment::USAePay shows that this particular processor actually has three different test modes.
# test_transaction(0): normal mode
# 1 : test mode (validates formatting only)
# 2 : use sandbox server
# 3 : test mode on sandbox server
It looks like you can set the server details in the constructor - it takes an optional hash of parameters beyond the processor name.
Have you tried something like:
my $tx = new Business::OnlinePayment(
"USAePay",
Server => 'https://sandbox.usaepay.com/gate'
);

cakePHP 3 link inside email view

I have an issue build a link inside an email view, it doesn't out put the URL i'm passing from the controller for some reason..
the URL string that i'm passing to the view is missing the http://domain prefix
some action in usersController:
$email = new Email(['gmail','transport'=>'gmail']);
$email->template('recover', 'default')
->emailFormat('html')
->viewVars([
'username' => $user['username'],
'url' => '/users/resetpwd/u/'.$user['username'].'/t/'.$user['token']
])
->from(['mailer#domain.com' => 'My Site'])
->to('example#domain.com')
->subject('Password recovery')
->send()
recover.ctp:
<p>Welcome <b><?= $username; ?></b>,<br/>
you requested a password change.<br/>
To set a new password, please: <?php echo $this->Html->link('Click Here', $url, ['_full' => true,'escape' => true]); ?></p>
<?= $this->Html->image('banniere.gif', array('fullBase' => true));?><br/>
<p>This email was sent from My Site</p>
If you want to ensure that the URL is always a "full" one, then the proper solution here is Router::url(). That way you could even declare the URL in array format (which should normally be the preferred style anyways) without breaking things.
use Cake\Routing\Router;
// ...
<?= $this->Html->link('Click Here', Router::url($url, true), ['escape' => true]); ?>

I am using MIME::Lite::TT to send mail with perl. How to save the mail locally before sending

Template
<html>
<body>
<strong>Hi [% first_name %]</strong>,
<p>
This is to confirm your purchase of $ [% amt_due %].
</p>
<p>
Thank you!
</p>
</body>
</html>
`$params{first_name} = 'Frank';
$params{last_name} = 'Wiles';
$params{amt_due} = '24.99';
my $msg = MIME::Lite::TT::HTML->new(
From => 'admin#example.com',
To => 'frank#example.com',
Subject => 'Your recent purchase',
Template => {
text => 'test.txt.tt',
html => 'test.html.tt',
},
TmplOptions => \%options,
TmplParams => \%params,
);
How to save the mail locally before sending. It is having template as html which is populated with params and a pdf attachment.
Is it possible to save the Template with populated values.
MIME::Lite::TT is just a preprocessor; calling MIME::Lite::TT->new returns a normal MIME::Lite object. Just save that object in whatever way you like.
For example, you can print it to a filehandle:
my $email = MIME::Lite::TT->new(...);
$email->print(\*STDOUT);
$email->send;
To print the populated template we can use
$$email{data}
As $email is a reference to a hash and data is a key to the contents of body of email.
To print the whole mail use the above solution.

SoundCloud API: Tweeting on upload and disable comments

The following PHP code uploads a new track to SoundCloud successfully, but the tweet is not sent.
Is there something I need to have in there as well in order to do this?
$track = $soundcloud->post('tracks',
array(
'track[asset_data]' => '#audio.mp3',
'track[title]' => "my audio",
'track[description]' => "Updated: " . date('l jS F Y h:i:s A'),
'track[sharing]' => 'public',
'track[shared_to][connections][][id]' => '123',
'track[sharing_note]' => 'Have a listen to'
));
Also I'd like to be able to disable comments on the audio I upload, but I wasn't sure what the parameter for that would be too?
Thanks!
dB
I'm unable the repro the sharing problem. Please note that sometimes sharing on other social networks doesn't happen right away. Are you still having trouble? Here's the code I used:
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud("foo", "bar");
$client->setAccessToken('ACCESS_TOKEN');
$track = $client->post('tracks', array(
'track[title]' => 'Foooo',
'track[asset_data]' => '#/Users/paul/audio.wav',
'track[sharing]' => 'public',
'track[shared_to][connections][][id]' => 'CONNECTION_ID',
'track[sharing_note]' => 'Check it out'
));
print_r($track);
Also verify that your CONNECTION_ID is correct. Some code to get a list of connections so you can verify the id:
<?php
require_once 'Services/Soundcloud.php';
$client = new Services_Soundcloud("foo", "bar");
$client->setAccessToken('ACCESS_TOKEN');
print_r(json_decode($client->get('me/connections')));
Unfortunately there's no way currently to disable comments via the API. I'll file a bug and see about getting this fixed.
Hope that helps!

How do I use Perl's WWW::Facebook::API to publish to a user's newsfeed?

We use Facebook Connect on our site in conjunction with the WWW::Facebook::API CPAN module to publish to our users newsfeed when requested by the user.
So far we've been able to successfully update the user's status using the following code:
use WWW::Facebook::API;
my $facebook = WWW::Facebook::API->new(
desktop => 0,
api_key => $fb_api_key,
secret => $fb_secret,
session_key => $query->cookie($fb_api_key.'_session_key'),
session_expires => $query->cookie($fb_api_key.'_expires'),
session_uid => $query->cookie($fb_api_key.'_user')
);
my $response = $facebook->stream->publish(
message => qq|Test status message|,
);
However, when we try to update the code above so we can publish newsfeed stories that include attachments and action links as specified in the Facebook API documentation for Stream.Publish, we have tried about 100 different ways without any success.
According to the CPAN documentation all we should have to do is update our code to something like the following and pass the attachments & action links appropriately which doesn't seem to work:
my $response = $facebook->stream->publish(
message => qq|Test status message|,
attachment => $json,
action_links => [#links],
);
For example, we are passing the above arguments as follows:
$json = qq|{ 'name': 'i\'m bursting with joy', 'href': ' http://bit.ly/187gO1', 'caption': '{*actor*} rated the lolcat 5 stars', 'description': 'a funny looking cat', 'properties': { 'category': { 'text': 'humor', 'href': 'http://bit.ly/KYbaN'}, 'ratings': '5 stars' }, 'media': [{ 'type': 'image', 'src': 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg', 'href': 'http://bit.ly/187gO1'}] }|;
#links = ["{'text':'Link 1', 'href':'http://www.link1.com'}","{'text':'Link 2', 'href':'http://www.link2.com'}"];
The above, nor any of the other representations we tried seem to work. I'm hoping some other perl developer out there has this working and can explain how to create the attachment and action_links variables appropriately in Perl for posting to the Facebook news feed through WWW::Facebook::API.
Thanks in advance for your help!
I think the problem is that your JSON string might be invalid. I was able to get it to work by just using JSON::Any to serialize a Perl data structure instead of building the JSON string manually. (WWW::Facebook::API uses JSON::Any under the hood; it would be nice if it could take a Perl data structure instead of a JSON string. I will try to submit a patch this weekend.)
use WWW::Facebook::API;
use JSON::Any;
my $j = JSON::Any->new;
my $fb = WWW::Facebook::API->new(
desktop => 0,
api_key => $api_key,
secret => $secret,
session_key => $session,
session_expires => $expires,
session_uid => $fb_uid
);
my $res = $fb->stream->publish(
message => 'Test message',
attachment => $j->objToJson(
{ name => 'Foo bar baz',
href => 'http://www.google.com/',
description => "this is a thing"
} ),
action_links => $j->objToJson(
[ { text => 'action link text',
href => 'http://www.foobar.com/'
} ] )
);
The result:
http://www.friedo.com/fb_attach.jpg