SES integration in Magento with code - magento

Please help me to integrate ses in magento as i have tried below method for sending email.But not getting any of the email in my inbox or spam.sendEmail()is not sending email.I have tried both for localhost and on server neither of them sending an email.
$config = array('auth' => 'login',
'username' => '***************',
'port'=>587,
'SMTP'=>true,// SMTP
'SMTPAuth' => true, // SMTP authentication
'Mailer' => "smtp",
'enable_starttls_auto' => true,
'host'=>"email-smtp.us-west-2.amazonaws.com",
'password' => '**************************');
ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
$ses = new SimpleEmailService($config);
$m = new SimpleEmailServiceMessage();
$m->addTo('xyz.test#gmail.com');
$m->setFrom('xyz.test#gmail.com');
$m->setSubject('You have got Email!');
$m->setMessageFromString('Your message');
if($ses->sendEmail($m)){
echo "done";die;
}
One of the try given me this error:-
stdClass Object ( [error] => Array ( [curl] => 1 [code] => 60 [message] => SSL certificate problem: unable to get local issuer certificate [resource] => ) )

Related

Mailgun API - Send URL as attachment in Send Email not working

I am trying to send url as attachment using Send Email api in Mailgun. But the attachment is not attached. I am using Laravel HTTP client
$params = [
'from' => $selected_options['mg_from_email'],
'to' => $selected_options['mg_to_email'],
'subject' => $selected_options['mg_subject'],
'text' => $selected_options['mg_text'],
'html' => $selected_options['email_body'],
];
$response = Http::asForm()->withOptions(['verify' => config('constants.verify_ssl')])->timeout(30)->withHeaders(
[
'Content-Type' => 'multipart/form-data',
'Authorization' => 'Basic ' . base64_encode('api:'.$api_key)
]
)->attach(
'attachment', file_get_contents('https://picsum.photos/200'), 'photo.jpg'
)->post(
$request_url,
$params,
);
Can anyone suggest what i am doing wrong here?
There is no error in response and the email is also sent successfully but the attachment is not there.

Laravel 5 Mail - Gmail - AbstractSmtpTransport.php line 399:Uninitialized string offset: 3

so i'm trouble getting a fairly difficult time getting my mail up and i'm not finding a comparable solution out there. I’m trying to send a basic email through gmail from my website using SMTP. Everything seems correct. Thanks for your help
• my account is xxx#gmail.com. i've set up the two step verification on this account. the xxx#gmail.com account has password a123
• i'm trying to send it from my email marketing#y.com. for xxx#gmail.com
• under gmail-settings-account and import- send mail as
• i have
o Marketing -Not an alias.
o Mail is sent through: smtp.gmail.com
o Secured connection on port 587
o using TLS
• clicking on edit info- Name:
o Marketing
o Email address: marketing#y.com
• Click Next - Edit email address - Send mail through your SMTP server
o Configure your mail to be sent through SamsSocial.com SMTP servers Learn more
o You are currently using: secured connection on port 587 using TLS
o To edit, please adjust your preferences below.
o SMTP Server: smtp.gmail.com
o Port: Username: xxx#gmail.com
o Password: OTHERPASS
o Secured connection using TLS (recommended)
i'm getting the following error and it's taking an incredibly long time
ErrorException in AbstractSmtpTransport.php line 399:
Uninitialized string offset: 3
in AbstractSmtpTransport.php line 399
at HandleExceptions->handleError('8', 'Uninitialized string offset: 3', 'C:\wamp\www\d\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php', '399', array('seq' => '8', 'response' => '�334 VXNlcm5hbWU6 L', 'line' => 'L')) in AbstractSmtpTransport.php line 399
at Swift_Transport_AbstractSmtpTransport->_getFullResponse('8') in AbstractSmtpTransport.php line 277
at Swift_Transport_AbstractSmtpTransport->executeCommand('AUTH LOGIN ', array('334'), array()) in EsmtpTransport.php line 270
at Swift_Transport_EsmtpTransport->executeCommand('AUTH LOGIN ', array('334')) in LoginAuthenticator.php line 40
controller
public function sendEmailReminder()
{
$user = User::findOrFail(1);
// dd(Config::get("mail"));
Mail::send('admin.marketing.emails.test', ['user' => $user], function ($m) use ($user) {
//i've had this with and without the from
$m->to('test#yahoo.com', 'peter')->subject('This is how we do it');
});
return redirect('admin/marketing');
}
Test.blade.php
Hi {{$user['name']}}. this is the first email we've sent
Config/mail.php
<?php
return [
'driver' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'Marketing#t.com', 'name' => 'Marketing'],
'encryption' => 'tls',
'username' => env('MAIL_USERNAME',xxx#gmail.com'),
'password' => env('MAIL_PASSWORD','OTHERPASS’),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxx#gmail.com
MAIL_PASSWORD=OTHERPASS
MAIL_ENCRYPTION=tls
When I do dd(Config::get("mail")); - I get the following which appears correct
array:9 [▼
"driver" => "smtp"
"host" => "smtp.gmail.com"
"port" => "587"
"from" => array:2 [▼
"address" => "Marketing#y.com"
"name" => "Marketing"
]
"encryption" => "tls"
"username" => "xxx#gmail.com"
"password" => "OTHERPASS"
"sendmail" => "/usr/sbin/sendmail -bs"
"pretend" => false
]
The error might be misleading, but it is actually caused because authentication against gmail smtp servers produced an unexpected output. Google has changed the way authorization works for client apps.
Now it is necessary to retrieve an App Password for the app that is accessing Mail or Calendar in your behalf, and use that App Password instead of the usual password that you use for web.
More info here: https://support.google.com/accounts/answer/185833?hl=en

Codeigniter[Angelleye library]: "Receiver PayPal accounts must be unique" error

I have used angelleye/paypal-codeigniter API for implementing the Paypal Adaptive Payment in my Codeigniter Project.
I have the similar setup like that of https://ci.angelleye.com/paypal/samples/demo/ ON MY LOCALHOST
I have developer paypal account which has 2 merchant sandbox account and one sender sandbox account.While payment I am transferring the funds from sender to 2 receivers.
On my localhost I clicked on the link of Adaptive Payment from the three libraries(Payments Pro , Adaptive Payments,PayFlow) mentioned on that page. Everything was working fine till some time back.
But unfortunately now on click of Adaptive Payment link I am getting following errors in $PayPalRequestData as RESPONSE:
Array
(
['Errors'] => array(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 579040
[ExceptionID] =>
[Message] => Receiver PayPal accounts must be unique.
[Parameter] => receiver
[Severity] => Error
[Subdomain] => Application
)
[Ack] => Failure
[Build] => 20420247
[CorrelationID] => 581ecdae58e50
[Timestamp] => 2016-03-04T01:41:05.725-08:00
[PayKey] =>
[PaymentExecStatus] =>
[RedirectURL] =>
[XMLRequest] => <displayed request string>
[XMLResponse] => <displayed response string>
)
Array
(
['Errors'] => array(
[0] => Array
(
[Receiver] =>
[Category] => Application
[Domain] => PLATFORM
[ErrorID] => 579017
[ExceptionID] =>
[Message] =>The amount for the primary receiver must be greater than
or equal to the total of other chained receiver amounts
[Parameter] => receiver
[Severity] => Error
[Subdomain] => Application
)
[Ack] => Failure
[Build] => 20420247
[CorrelationID] => d85cb50b00e2e
[Timestamp] => 2016-03-04T01:46:01.853-08:00
[PayKey] =>
[PaymentExecStatus] =>
[RedirectURL] =>
[XMLRequest] => <displayed request string>
[XMLResponse] => <displayed response string>
)
The REQUEST I sent is
$Receiver = array(
'Amount' = '12.00',
'Email' = 'receiver_1#domain.com',
'InvoiceID' = '123-ABCDEFG',
'PaymentType' = 'SERVICE',
'PaymentSubType' = '',
'Phone' = array('CountryCode' = '', 'PhoneNumber' = '',
'Extension' = ''),
'Primary' = 'true'
);
$Receiver = array(
'Amount' = '5.00',
'Email' = 'receiver_2#domain.com',
'InvoiceID' = '123-ABCDEFG',
'PaymentType' = 'SERVICE',
'PaymentSubType' = '',
'Phone' = array('CountryCode' = '', 'PhoneNumber' = '',
'Extension' = ''),
'Primary' = 'true'
);
Can someone please tell me what there errors are? and how to solve those errors.

Sending mail with SwiftMailer in Laravel 4

I am receiving a the following error:
Cannot send message without a recipient
This is while trying to send a email using swiftmailer. My code works in localhost and has all the parameters needed from sender to receiver but it throws an error saying it cannot send without recipient.
Here is my code:
public function email()
{
Mail::send('emails.auth.mail', array('token'=>'SAMPLE'), function($message){
$message = Swift_Message::newInstance();
$email = $_POST['email']; $name = $_POST['name']; $subject = $_POST['subject']; $msg = $_POST['msg'];
$message = Swift_Message::newInstance()
->setFrom(array($email => $name))
->setTo(array('name#gmail.com' => 'Name'))
->setSubject($subject)
->setBody($msg);
$transport = Swift_MailTransport::newInstance('smtp.gmail.com', 465, 'ssl');
//$transport->setLocalDomain('[127.0.0.1]');
$mailer = Swift_Mailer::newInstance($transport);
//Send the message
$result = $mailer->send($message);
if($result){
var_dump('worked');
}else{
var_dump('Did not send mail');
}
}
}
You can do this without adding your the SMTP information in your Mail::send() implementation.
Assuming you have not already, head over to app/config/mail.php and edit the following to suit your needs:
'host' => 'smtp.gmail.com',
'port' => 465,
'encryption' => 'ssl',
'username' => 'your_username',
'password' => 'your_password',
Then your code should be as simple as:
public function email()
{
Mail::send('emails.auth.mail', array('token'=>'SAMPLE'), function($message)
{
$message->from( Input::get('email'), Input::get('name') );
$message->to('name#gmail.com', 'Name')->subject( Input::get('subject') );
});
}
So, hopefully the issue is one of configuration. Do you have other environments setup that might be over-riding the app/config/mail.php configuration settings in your server where it's not working?
Please make sure you have configured all the necessary configuration correctly on
/app/config/mail.php. Ensure all the configuration is correct for the environment where the email is not working correctly.
If you want to use your Gmail account as an SMTP server, set the following in app/config/mail.php:
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'encryption' => 'ssl',
'username' => 'your-email#gmail.com',
'password' => 'your-password',
When switching to online server, you want to protect this file or switch provider so as not to expose your gmail credentials. Port 587 is for mailgun not gmail.

CodeIgniter Payments Getting a Success Response but not Working

I'm using CodeIgniter Payments to integrate with the Paypal API. I believe I am calling the right methods because I'm getting a response of "Success" but I don't see the transaction in the Sandbox. When I use the sample DoDirectPayment file from Paypal I complete the transaction and I can see it in the sandbox.
Here is my code using CodeIgniter Payments:
//load the payment library
$this->load->spark('codeigniter-payments/0.1.4/');
//configure the parameters for the payment request
$paymentParameters = array(
'cc_type' => 'foo',
'cc_number' => 'foo',
'cc_exp' => 'foo',
'first_name' => 'foo',
'last_name' => 'foo',
'street' => 'foo',
'street2' => 'foo',
'city' => 'foo',
'state' => 'foo',
'country' => 'foo',
'postal_code' => 'foo',
'amt' => 'foo',
'currency_code' => 'USD'
);
//make the call
$paymentResponse = $this->payments->oneoff_payment('paypal_paymentspro', $paymentParameters);
//print the response
print_r($paymentResponse);
Here is the response:
stdClass Object
(
[type] => gateway_response
[status] => Success
[response_code] => 100
[response_message] => The authorization was successful.
[details] => stdClass Object
(
[gateway_response] => stdClass Object
(
[TIMESTAMP] => 2012-05-22T19:18:17Z
[CORRELATIONID] => 7939eeaa6c0c0
[ACK] => Success
[VERSION] => 66.0
[BUILD] => 2929894
[AMT] => 20.89
[CURRENCYCODE] => USD
[AVSCODE] => X
[CVV2MATCH] => M
[TRANSACTIONID] => 4RS01101TL8204042
)
[timestamp] => 2012-05-22T19:18:17Z
[identifier] => 4RS01101TL8204042
)
)
You can just switch into using other Paypal libraries. It might save you time than figuring out this problem. http://codeigniter.com/wiki/PayPal_Lib
I had this problem too.
In my case, I did not set my config driver correctly and it ended up sending all my transactions to Calvin's (Author's) default paypal sandbox account.
Double check to make sure that your API tokens are set correctly with:
$gateway_name = 'paypal_paymentspro';
$params = array(
'identifier' => *Your transaction ID from above*
);
$response = $this->payments->get_transaction_details($gateway_name, $params);
print_r($results);
Also, if you don't want to set the driver and want to do everything from your PHP file, you can always pass in your API tokens like so:
$gateway_name = 'paypal_paymentspro';
$params = array(
'identifier' => *Your transaction ID from above*
);
$config['api_username'] = *Your api username*;
$config['api_password'] = *Your api password*;
$config['api_signature'] = *Your sig*;
$response = $this->payments->get_transaction_details($gateway_name, $params);
print_r($results);

Resources