Laravel SwiftMailer Different Domains - php

I have an web application that is supposed to send emails with bounce controlling and analytics integration and i have an mail code like this:
Mail::send('emails.newsletter', [
'unsub_code' => $this->contact[$i][3],
'emailTo' => $this->contact[$i][1],
'emailFrom' => $this->email,
'user' => $this->contact[$i][0],
'UUID' => $this->contact[$i][2],
'campaignName' => $this->campaign->name,
'campaignId' => $this->campaign->id,
'header' => $header,
'body' => utf8_encode(html_entity_decode($this->campaign->body)),
'footer' => html_entity_decode($this->campaign->footer)],
function ($m) use ($i) {
$m->from('email#mydomain.ss', 'AAB');
$m->to($this->contact[$i][1])->subject($this->campaign->subject);
$headers = $m->getHeaders();
$headers->addPathHeader('Return-Path', 'bounce#mydomain.something');
$headers->addTextHeader('uuid', $this->contact[$i][2]);
$headers->addTextHeader('cpName', $this->campaign->name);
$headers->addTextHeader('cpId', $this->campaign->id);
});
My problem is that i want to send emails from other#otherdomain.xx but maintain the bounce#mydomain.ss but that gives me an error because the other#otherdomain isnt the same as the env one.

Well like jszobody pointed in the comments this is actually a problem with my hosting blocking me from sending email from other domains, this will actually be solved by purchasing another service from them which enables me to do so.
Since i'm developing the application i don't want to use a third-party SMTP provider which is also a good solution cost wise.

Related

How to send batch/mass emails with attachments using mailgun?

I want to send batch emails with attachment. I can send the batch emails by attaching the same file to all the emails. But I need to attach different files to different emails by adding file path in recipient variables. I can't see anything related in the official documentation of mailgun.
Here is my code :
# Instantiate the client.
$mgClient = new Mailgun('key-****');
$domain = "foo.bar.com";
# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'gido#foo.baar.com',
'to' => array('user1#gmail.com', 'user2#gmail.com'),
'subject' => 'Hi %recipient.first%',
'text' => 'Hey there, Just Testing',
'recipient-variables' => '{"user1#gmail.com": {"first":"User1", "id":1, "file" : "/path/to/file1"},
"user2#gmail.com": {"first":"User2", "id": 2, "file" : "/path/to/file2"}}'
), array(
'attachment' => array('%recipient.file%')
));
The above code does not work. the attachment array is not able to use recipient variable. Replacing %recipient.image% with /path/to/file works fine.
As per conversation with the Mailgun support team, At this time Mailgun doesn't have a way to assign a specific attachment to each recipient. One thing that can be tried is serving the files on a server and assign the users a URL to retrieve the file from(This is suggested only in case if files are not confidential and stored permanently on the server.).
From the doc:
'attachment' => [['fileContent'=>$binaryFile,'filename'=>'test.jpg']]
OR
'attachment' => [['filePath'=>'/tmp/foo.jpg','filename'=>'test.jpg']]
OR (inline):
'inline' => [['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg']]

Sendgrid can't receive emails in application

I'm trying to receive e-mails sended to my account on sendgrid.
So What I basically have is the following:
A sendgrid account linked to http://www.rallypodium.be
A cloudflare account linked to http://www.rallypodium.be server IP adress.
A server on DigitalOcean.
Good, So I'm running Nginx on that server and I want to be able to get the e-mails send to #rallypodium.be to be saved and stored inside of my database wich is on the same DigitalOcean server.
I've set up the Inbound Parse like this:
HOST: www.rallypodium.be
URL: http://www.rallypodium.be/inbound/parse/mail
My domain is whitelabled.
I've read the docs for 10 times and still didn't figure out what I'm doing wrong.
This is how I store them:
public function ReceiveMail(Request $request)
{
DB::table('email')->insert([
'headers' => $request->get('headers'),
'html' => $request->get('html'),
'from' => $request->get('from'),
'to' => $request->get('to'),
'cc' => $request->get('cc'),
'subject' => $request->get('subject'),
'dkim' => $request->get('dkim'),
'spf' => $request->get('spf'),
'envelope' => $request->get('envelope'),
'charsets' => $request->get('charsets'),
'spam_score' => $request->get('spam_score'),
'spam_report' => $request->get('spam_report'),
'attachments' => $request->get('attachments'),
'attachment-info' => $request->get('attachment-info'),
'attachmentX' => $request->get('attachmentX')
]);
return 'ok';
}
If I take a look at the Activity Feed, then I see this:
The error message is the following:
EMAIL: robin#rallypodium.be
REASON: error dialing remote address: dial tcp 104.24.101.114:25: i/o timeout
SMTP-ID: <1f7f313f27fd051b525581562e6af9b5#rallypodium.be>
PROCESSED STRING: August 1, 2016 - 06:53:45PM
MSGID: J1irmehmR_GELI7tIpPXNg.filter0810p1mdw1.1861.579F77CC27.0
oh and this is my cloudflare DNS: http://prntscr.com/c0bjl8
Can someone help me out?
Thanks!
You are essentially trying to receive email through CloudFlare, but unfortunately CloudFlare doesn't proxy SMTP/email traffic.
Instead you'll need to add a grey-clouded record to manage your email, this will allow your email to be routed straight to your origin without CloudFlare blocking it. Note that grey clouded domains can reveal your IP Address, it is therefore recommended to have your email server on a separate server to your webserver; or even better use a Cloud email provider and get emails from them.

ALL GCM parameters?

i´ve written a "pushserver" for my app via PHP.
The push notifications i´ve sent via PHP are all received on the device, so far.
But, i can just send/set the "message" and "title", see:
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array(
'message' => $message,
'title' => 'My App',
'vibrate' => 1,
'sound' => 1,
'icon' => "http://example.com/image.jpg",
"style" => "inbox"
),
);
"icon" and "style" are not working (vibrate and sound not tested, yet).
Every link for the parameters i´ve found is broken or kind of "you need to do object.setSomething() in JAVA.
Is there a list anywhere where i can see ALL parameters, which i can send to GCM? No matter, what language i use?
Cheers,
Chris
couple of things need to keep in mind while all the data which you sending from server end
Is there a list anywhere where i can see ALL parameters,
exp :- you can send as many parameters as you want but offcourse there is limitation but not key specific just like you can use "textmessage" instead of "message" but make sure to retrieve the value from same key which you are assigning from server end
1) please make sure that you are getting all the data in gcmintentservice class try to print the log of all intent data.
please remember that this is just a string data it is not going to download the image for you. you have to download using volley library or any suitable library

CakePHP emails suddenly stopped working

I have been using CakePHP's email class for close to a year now. The system has been sending html emails without problems. Two days ago I received reports that customers were not receiving their notifications. I noticed as well that I wasn't receiving my admin notifications.
My first thought was something changed with my server (hosted by GoDaddy). I do not believe it is my hosting provider as I have tested a php's raw mail() function and even sent a quick text email through CakePHP's class. I also tested each debug mode and error logs, nothing to indicate an error occurred. Here is the code I have been using (successfully) since a couple days ago. This code is the same around 10 times throughout my app.
$Email = new CakeEmail();
$Email->template('order_status_change', 'default')
->emailFormat('html')
->to($order['Order']['email'])
->subject('blah blah ' . $order['Order']['id'] . ' status change: ' . $status['Status']['label'])
->from(array('myemail#gmail.com' => 'blah blah'))
->viewVars(array(
'id' => $order['Order']['id'],
'firstName' => $order['Order']['first_name'],
'statusLabel' => $status['Status']['label'],
'statusDescr' => $status['Status']['description']
))
->send();
A couple things to note:
I have confirmed that the html template 'order_status_change' and
default layout are in the correct folders (they were working before)
I have confirmed that the variables are all correctly set at the
time of email
If I have to switch to text emails I will but I cannot seem to fathom how the code would suddenly stop working. The only thing I have changed is the debug mode (which I have been doing since the beginning).
Update
Emails stopped working again so I switched over to text mail. However for some odd reason when I put a url in the body (like http://www.google.com) the mail fails. However if I remove just the .com then it will go through. What the hell is happening?
Update 2
This is my current config that will send out text emails without links in them (when I say links I mean a url string)
class EmailConfig {
public $godaddy = array(
'transport' => 'Smtp',
'host' => 'relay-hosting.secureserver.net',
'port' => 25,
'timeout' => 300,
'log' => true,
'charset' => 'utf-8',
'headerCharset' => 'utf-8'
);
}
I confirmed that Go Daddy does not need authentication and the port is 25.

hotmail: user authentication and contact retrieval with PHP

I am trying to write a PHP script that will allow me to do two things:
Allow users to use their Hotmail (I think its called 'Live' now?) account to authenticate themselves to a website
Retrieve an authenticated users contact list from Hotmail.
I have trawled the internet for the past 6 hours, looking for at least a working example that I can modify/extend to do the above two things. There are several dozens similar questions asked here on SO for example - NONE of the proffered answers work any more (admittedly, some of the questions were a few years old).
I tried the Microsoft site and downloaded the latest version of their API which seems to evolve at a rather alarming rate. I finally managed to track down an API which has not been deprecated (yet?).
I followed the instructions and when I attempted to authenticate, I was rewarded with the following mesage, for my efforts:
We're unable to complete your request
Windows Live ID is experiencing technical difficulties. Please try again later.
I immediately tried the online version of the demo and perhaps unsurprisingly, that worked like a charm.
As an aside, I managed to implement the same functionality for Yahoo and GMail, using their OPEN APIs, under an hour each. Now, it is possible that my unmitigated hatred of all things proprietary (sorry make that Microsoft), is causing me to lose the plot a little here.
Has anyone ACTUALLY (in 2012) managed to get a working sample in PHP that allows:
Hotmail (live?) user authentication
Hotmail user contact email retrieval
If you have, a code snippet, or a link to where I can find such a snippet would be very useful, as I have so far, wasted a whole afternoon trying to work the Microsoft Live API via PHP.
PS: No, I'm not interested in OpenInviter, its broken.
i wrote my own oauth library based around a single array for each service provider. this array contains all of the data required to perform authentication and retrieve user data. the array i use for msdn (ie. hotmail, outlook, xbox, msn) is:
$msdn = array
(
'oauth_version' => '2',
'oauth_method' => 'GET',
'redirect_user_params' => array
(
'url' => 'https://oauth.live.com/authorize',
'response_type' => 'code',
'http_params' => array
(
'url',
'client_id',
'redirect_uri',
'response_type',
'scope',
'state'
)
),
'obtain_access_token_params' => array
(
'url' => 'https://oauth.live.com/token',
'grant_type' => 'authorization_code',
'http_params' => array
(
'url',
'client_id',
'client_secret',
'code',
'grant_type',
'redirect_uri',
'scope'
)
),
'scope' => 'wl.signin wl.basic',
'obtain_user_data_params' => array
(
'url' => 'https://apis.live.net/v5.0/me',
'http_params' => array
(
'url',
'access_token',
'scope'
)
),
'client_id' => 'xxxxx', // = oauth_consumer_key in oauth 1.0 lingo
'client_secret' => 'xxxxxxxxxxxxxxx',
'readme_url' => 'http://msdn.microsoft.com/en-us/library/live/hh243647.aspx'
);
the parameters for each of the three oauth stages (ie "redirect user", "obtain access token" and "obtain user data") are in the http_params arrays. in the case of msdn these parameters end up in the query query string of the url that i send out with curl (since msdn only accepts GET, not POST).
i haven't tried retrieving the user's contact address book, but this would just be a case of extending the scope element with whatever extra information you require (documented here http://msdn.microsoft.com/en-us/library/live/hh243646.aspx). as you can see from the http_params arrays, the scope parameter is used in each of the three oauth stages.
Try out a Hotmail/MSN/Live import on the CloudSponge test drive to see if that's the user experience you're hoping for.
If it works for you, you can use our widget or our API. If you want to use the API, we have a PHP wrapper already written for your convenience.
Please confirm your callback url is with http:// if you only put www.domain.com then get this issue..

Categories