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.
Related
I am using laravel-imap to connect to my email server and get all mailboxes and messages.
I noticed that the connect() method is slow, it takes 4-5 sec.:
$start = microtime(true);
$oClient = new Client([
'host' => env('MAIL_HOST_IN'),
'port' => env('MAIL_PORT_IN'),
'encryption' => env('MAIL_ENCRYPTION_IN'),
'validate_cert' => true,
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'protocol' => 'imap'
]);
// Connect to the IMAP Server
$oClient->connect();
\Log::info('Connect: ' . strval(microtime(true) - $start));
Thats it, there is no additional code. I also use getFolders() and loop through them to get messages.
I count/get unseen messages and do more operations, but they are all fast.
I am asking this, because if I login into my mailbox through the website, the performance is much better 1-2 sec. And the operation is the same, I get the mailboxes and a count on unseen messages. So why it is slow via script?
In case it simply is like that and I cant change it, what are some possible solutions? The only idea I have right now it to reuse the connection in multple functions, so at least I connect only once.
Thanks #everyone who commented.
I can confirm now that there is no issue with the code/package.
It seems that something on my local machine was responsible for the slow connect time.
I dont know exactly what it was, maybe a broken firewall.
I uploaded the code to my server. The performance was much better, it connected immediately.
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.
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.
I am trying to send a simple email using Mandrill and everything works well until I put too much text into the text field, here is what I mean:
$message = array(
'subject' => $subject,
'text' => $content,
'from_email' => 'myemail#gmail.com',
'to' => array(
array(
'email' => $toMail,
)
)
);
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
So when $content contains more than about 1000 characters the email does not send and I get a 500 error, which seems to be an API timeout. However I need to send emails with up to 20000 characters in them. Has this happened to anyone? Also this worked a couple months ago for me, I am not sure why it does not work anymore.
I saw that SMTP headers can only be 1000 characters long, but the text segment doesn't land in the header does it?
UPDATE: So interestingly enough, it still works fine on my main computer. I moved the website to another machine running ubuntu 14.04 and that is where the error started appearing. Anybody have any ideas as to why?
What I'm doing:
I use SugarCRM.
At first I complete email settings in /index.php?module=EmailMan&action=config. Test letter send fine. That works OK.
Then I create new emailing list using module "Campaigns". Then I move to a wizard to create new email /index.php?action=WizardMarketing&module=Campaigns.... and send emails.
Finally emails are sent. I watch og and see "SUCCESS" (warn only here because I changed its logging status in code from debug to warn):
Mon Sep 10 11:17:42 2012 [13138][1][WARN] Email delivery SUCCESS:Array
(
[date_entered] => 2012-09-10 07:17:20
[date_modified] =>
[user_id] => 1
[id] => 118
[campaign_id] => 362acd98-9980-c24b-921e-5020db524444
[marketing_id] => a00e472d-6026-6fc6-8919-5020db14f6a8
[list_id] => 9ac9c172-feb3-1024-bf2a-5018f1e4074b
[send_date_time] => 2012-09-10 05:05:00
[modified_user_id] =>
[in_queue] => 0
[in_queue_date] =>
[send_attempts] => 0
[deleted] => 0
[related_id] => ec106592-598f-9b45-e3e4-5022647678a6
[related_type] => Prospects
)
So seems like everything is ok. But.. I don't receive any email. And also I don't see any sent emails on DetailView (/index.php?action=DetailView&module=Campaigns....).
But they can be found in Blocked emails!
What I've done:
I tried to change email setting in EmailMan module config for inbox/outbox. Seems like they work fine with test emails. Also i tried to find php problems and changed modules\EmailMan\EmailManDelivery.php logging for success email from debug to warn to make them showing in *.log file.
Question:
Why are my emails blocked. And what do I need to do to make them send successfully?
Thanks for any help and ask my if more info is needed.
Ok, I luckily found problem just a second ago on one forum about Sugar. The problem with Blocked emails was... that system don't send two or more emails on one adress, so other tries were blocked. Creating new Marketing Company solves this problem.