Bluehost's mail server seems not be sending my emails from Swiftmailer - php

I've a laravel app nad I've been testing it with gmail smtp server and It was working in my system's localhost but then I deployed it on server (blue host) and change the configuration and still the app thinks that is sending emails and it's not giving me errors but no email is delivered to corresponding email addresses....
Here's my mail.php in app folder:
return array(
'driver' => 'smtp',
'host' => 'mail.mash-up.fi',
'port' => 26,
'from' => array('address' => 'registration#mash-up.fi', 'name' => 'Admin'),
'encryption' => 'tls',
'username' => '************',
'password' => '******',
'sendmail' => '/usr/bin/sendmail -bs',
'pretend' => false,
);
where I'm doing wrong?
any help is appreciated

If you are using the BH DNS(ns1.bluehost...), then check to see that the $from address is an existing email in your BH account.
(go to your CP /domain manager and use whois info to find that out.)
or.....
maybe, you migrated the source code, but did you transfer your domain name to BH, or is it pointing to BH servers (DNS)
In that case your site is not using the BH mail servers.
example :your site content could be on BH, but if it is registered somewhere else and the DNS is not ns1.bluehost.com..etc, then your domain might be using url forwarding or framing (to bring visitors to the BH location). but your mail functions may be handled by the registrar's
hope this is not too confusing
it is also helpfull if you post your domain name here and others can help figure out as well.

Please try to check the spam folder of where your sending to. If there is nothing, make sure your "from" is truly your bluehost email account your using to send the email. If the actual sender doesn't match the "from" of the e-mail many mail clients will ignore it entirely (like hotmail), but gmail will put it in the spam folder with a warning.
The host should be your bluehost box I think. In fact on cpanel, go to email, where you create accounts. Then click on "More", select "Configure Email Client", scroll down. You will see the host name, and port.
TTL/SSL would likely need port 465, I am guessing (I use the latter, not the former like you).

Open up the laravel.logs file inside of storage > logs. It should help give you some idea of what the problem might be.

Related

Laravel mail sending is not working in the cloud instance [duplicate]

When I try to send an e-mail through my website running Laravel 4, I get this exception:
{"error":{"type":"Swift_TransportException","message":"Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 http:\/\/support.google.com\/mail\/bin\/answer.py?answer=14257 y70sm14744455qgd.3 - gsmtp\r\n\"","file":"\/var\/www\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php","line":386}}
Here is my mail config:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'mymail#gmail.com', 'name' => 'myname'),
'encryption' => 'ssl',
'username' => 'mymail#gmail.com',
'password' => 'lol',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I've tried the disable link i've found by googling this issue except it didn't make a difference.
Is there a way to tell Google "stop blocking this IP, it's me" ?
I tried the same thing and got the same error. So i personally checked my gmail account and i had a message from Gmail itself letting me know that they'd blocked an access attempt to my email account.
They showed an option to disable this security setting by visiting https://www.google.com/settings/security/lesssecureapps.
Things will actually be more straight forward if you visit that link already logged in into your Gmail account.
Warning
As #kodfire stated:
On May 30, 2022, this setting will no longer be available.
support.google.com/accounts?p=less-secure-apps&hl=en
Go to this link and disable unlock Captcha
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Try this:
Change port to 587
Goto gmail setting https://www.google.com/settings/security/lesssecureapps
and active it.
https://www.google.com/settings/security/lesssecureapps and active it.
https://accounts.google.com/b/0/DisplayUnlockCaptcha and active it.
'port' => env('MAIL_PORT', 587), <br>
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
I had lot of issues finding answer for this. Then after doing lot of trial and error i have found an solution to this. Most of the solution above worked for other but it help me upto 50%.
So, This is how it worked for me (100%):
Activate 2 step Verification in google
Now you will be able to create app. Open it.
Create new app (other app) and give your app name.
Now generate password.
Next in laravel, Goto .env file and change
MAIL_USERNAME= 'App Name you created'
MAIL_PASSWORD= 'Generated Password for that app'
This should be able to send emails from your gmail account.
Please leave a comment if it doesn't works for you.
Did you activate 2-step google authentification? If so, you need to define a new "application-specific password" password: http://www.google.com/landing/2step/.
Remove the #gmail.com from username, already you mentioned smtp. So no need #gmail.com on your username. I'm 100% sure it is your problem, because I had that problem.

Test mail using gmail smtp using swiftmailer? [duplicate]

When I try to send an e-mail through my website running Laravel 4, I get this exception:
{"error":{"type":"Swift_TransportException","message":"Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 http:\/\/support.google.com\/mail\/bin\/answer.py?answer=14257 y70sm14744455qgd.3 - gsmtp\r\n\"","file":"\/var\/www\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php","line":386}}
Here is my mail config:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'mymail#gmail.com', 'name' => 'myname'),
'encryption' => 'ssl',
'username' => 'mymail#gmail.com',
'password' => 'lol',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I've tried the disable link i've found by googling this issue except it didn't make a difference.
Is there a way to tell Google "stop blocking this IP, it's me" ?
I tried the same thing and got the same error. So i personally checked my gmail account and i had a message from Gmail itself letting me know that they'd blocked an access attempt to my email account.
They showed an option to disable this security setting by visiting https://www.google.com/settings/security/lesssecureapps.
Things will actually be more straight forward if you visit that link already logged in into your Gmail account.
Warning
As #kodfire stated:
On May 30, 2022, this setting will no longer be available.
support.google.com/accounts?p=less-secure-apps&hl=en
Go to this link and disable unlock Captcha
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Try this:
Change port to 587
Goto gmail setting https://www.google.com/settings/security/lesssecureapps
and active it.
https://www.google.com/settings/security/lesssecureapps and active it.
https://accounts.google.com/b/0/DisplayUnlockCaptcha and active it.
'port' => env('MAIL_PORT', 587), <br>
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
I had lot of issues finding answer for this. Then after doing lot of trial and error i have found an solution to this. Most of the solution above worked for other but it help me upto 50%.
So, This is how it worked for me (100%):
Activate 2 step Verification in google
Now you will be able to create app. Open it.
Create new app (other app) and give your app name.
Now generate password.
Next in laravel, Goto .env file and change
MAIL_USERNAME= 'App Name you created'
MAIL_PASSWORD= 'Generated Password for that app'
This should be able to send emails from your gmail account.
Please leave a comment if it doesn't works for you.
Did you activate 2-step google authentification? If so, you need to define a new "application-specific password" password: http://www.google.com/landing/2step/.
Remove the #gmail.com from username, already you mentioned smtp. So no need #gmail.com on your username. I'm 100% sure it is your problem, because I had that problem.

Send Email using Outlook through PHP Pear

I'm trying to send an email using PHP Pear. It works when I send email using Gmail with this settings:
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'username#gmail.com',
'password' => 'password!2016'
));
But before I make this work, I have to "allow less secure apps" to access my account, which you can read here on how to do it.
I tried to use an Outlook account with this settings:
$smtp = Mail::factory('smtp', array(
'host' => 'tls://smtp.office365.com',
'port' => '587',
'auth' => true,
'username' => 'email#domain.org',
'password' => 'greatPasswordComesWithGreatResponsibilities'
));
but I get this error:
Failed to connect to ssl://smtp.office365.com:587 [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.office365.com:587 (Unknown error) (code: -1, response: )]
I checked the official article by Microsoft regarding their SMTP settings. So I thought I have the right settings, but it's not working.
Am I missing something? Why do I get this error? Is there a setting I have to configure in my outlook account, like with the Gmail, before a third party app be allowed to send email?
This may not help but the title of your post just said Outlook account but the link and smtp settings refer to Office365 for Business accounts. I can't shed any light on the business account but if you actually have a personal Outlook.com account the settings are different. And, there is an option on the account you must change to enable pop/smtp access as you did with gmail.
The official Microsoft article is:
https://support.office.com/en-us/article/Add-your-Outlook-com-account-to-another-mail-app-73f3b178-0009-41ae-aab1-87b80fa94970?ui=en-US&rs=en-US&ad=US&fromAR=1
But, the summary is the smtp server is smtp-mail.outlook.com and to enable pop/smtp in your Outlook account look for Options > Managing your account > Connect devices and apps with POP.
Update:
If you are actually using business account, you should check this post which claims to have it working: https://stackoverflow.com/a/26004690/2891120
The key item in his code is he doesn't have "tls://" in front of the host name. I have a consumer outlook account and get a similar socket failure to you with tls:// prefix. If I remove that prefix I get much farther (set debug=true in factory) but fail later with an auth failure. Using 5.2.16 PHPMailer instead I successfully send mail but the headers leave me worried about spam rejection rates (no DKIM, SPF was softfail for my AWS entity, warning about -f, and others). And, the email did end up in the junk folder of my other test recipient #outlook.com. But I digress.

Laravel Gmail not working, "Username and Password not accepted. Learn more..."

When I try to send an e-mail through my website running Laravel 4, I get this exception:
{"error":{"type":"Swift_TransportException","message":"Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 http:\/\/support.google.com\/mail\/bin\/answer.py?answer=14257 y70sm14744455qgd.3 - gsmtp\r\n\"","file":"\/var\/www\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php","line":386}}
Here is my mail config:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'mymail#gmail.com', 'name' => 'myname'),
'encryption' => 'ssl',
'username' => 'mymail#gmail.com',
'password' => 'lol',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I've tried the disable link i've found by googling this issue except it didn't make a difference.
Is there a way to tell Google "stop blocking this IP, it's me" ?
I tried the same thing and got the same error. So i personally checked my gmail account and i had a message from Gmail itself letting me know that they'd blocked an access attempt to my email account.
They showed an option to disable this security setting by visiting https://www.google.com/settings/security/lesssecureapps.
Things will actually be more straight forward if you visit that link already logged in into your Gmail account.
Warning
As #kodfire stated:
On May 30, 2022, this setting will no longer be available.
support.google.com/accounts?p=less-secure-apps&hl=en
Go to this link and disable unlock Captcha
https://accounts.google.com/b/0/DisplayUnlockCaptcha
Try this:
Change port to 587
Goto gmail setting https://www.google.com/settings/security/lesssecureapps
and active it.
https://www.google.com/settings/security/lesssecureapps and active it.
https://accounts.google.com/b/0/DisplayUnlockCaptcha and active it.
'port' => env('MAIL_PORT', 587), <br>
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
I had lot of issues finding answer for this. Then after doing lot of trial and error i have found an solution to this. Most of the solution above worked for other but it help me upto 50%.
So, This is how it worked for me (100%):
Activate 2 step Verification in google
Now you will be able to create app. Open it.
Create new app (other app) and give your app name.
Now generate password.
Next in laravel, Goto .env file and change
MAIL_USERNAME= 'App Name you created'
MAIL_PASSWORD= 'Generated Password for that app'
This should be able to send emails from your gmail account.
Please leave a comment if it doesn't works for you.
Did you activate 2-step google authentification? If so, you need to define a new "application-specific password" password: http://www.google.com/landing/2step/.
Remove the #gmail.com from username, already you mentioned smtp. So no need #gmail.com on your username. I'm 100% sure it is your problem, because I had that problem.

CakePHP Cake Email SMTP Gmail

I have a problem with getting Cake Email to work properly.
I set everything up exacly as specified in cookbook (http://book.cakephp.org/2.0/en/core-utility-libraries/email.html section 'Configuration'). When I test it on localhost (xampp) everything works like a charm, the problem is, when I upload files on my web server, and try to execute it (send email) I get "Network is unreachable".
It seems to me, that there is probably some issue on server-side, but what could that be, and how to fix that?
Thanks in advance.
EDIT:
My code, as requested.
/app/Config/email.php
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'wykresl***14#gmail.com',
'password' => '***********',
'transport' => 'Smtp',
'timeout' => '30'
);
in Controller
public function test()
{
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail('gmail');
$Email->from(array('wykreslanka.2014#gmail.com' => 'Wykreślanka 2014'));
$Email->to('si***1#gmail.com');
$Email->subject('test');
$Email->template('newsletter');
$Email->emailFormat('html');
$Email->viewVars(array('post_id'=>0,'post_title'=>'Tytuł','post_body'=>'Body','quote_is'=>false));
$Email->send();
$this->Session->setFlash('Poszło','success');
return $this->redirect(array('action' => 'all'));
}
Typically, most web hosting services block external SMTP connections for some reason I'm still trying to understand. One such webhost I know is JustHost.
They want you to use their local smtp server... I would suggest you get in contact with your webhosting service a I'm 100% sure its something on their part and not with your code.
My webhost refused to listen so the best alternative I used was MailGun http://www.mailgun.com/
This allows you to send an email using an php-api that they provide. However you wont be able to use your gmail address.

Categories