UserFrosting (0.3.x) SMTP email error - php

[UserFrosting 0.3.x]
I just set up UserFrosting, and everything looks to be working, except one tiny thing...
When a user goes to register, there's an error "Fatal error attempting mail, contact your server administrator"
In the config-userfrosting.php, the smtp section is filled out as:
'mail' => 'smtp',
'smtp' => [
'host' => 'smtp.scottywcreates.com',
'port' => 465,
'auth' => true,
'secure' => 'ssl',
'user' => 'userfrosting#scottywcreates.com',
'pass' => '------'
],
(password blacked out)
Why am I getting this error?

The message that the user sees is just a generic error message, indicating that there was some problem with the mail server. It purposefully avoids giving specific details, that you may not want to disclose to the general public.
To find out the specific error condition, you will need to check your PHP error log. Please check with your particular server configuration to find the location of the PHP error log.
UserFrosting uses PHPMailer to send mail. By default, PHPMailer doesn't output any detailed SMTP error information, so you will likely see a generic exception message in the error log as well (for example, "SMTP Error: Could not authenticate.")
To obtain more detailed error information, you can hack userfrosting/models/Notify/Notification.php and change PHPMailer's default settings. Add the following configuration values to the other SMTP configuration values:
$mail->Debugoutput = 'error_log';
$mail->SMTPDebug = 4;
This will tell PHPMailer to dump very detailed connection and error information to the PHP error log. Once you do this, you should be able to see why exactly your SMTP server is rejecting UserFrosting's emails.
Common reasons that SMTP fails:
Many SMTP servers require that the authenticated account (in your case, userfrosting#scottywcreates.com) matches the From address in the actual email. By default, account verification emails are sent from the "Account Management Email" address set under Configuration -> Site Settings. So, you might try checking that it matches the address you use to authenticate in config-userfrosting.php.
Using the wrong port or authentication method. See the Email Troubleshooting wiki.

Related

SMTP email not working in Xampp locally hosted wordpress website

I am working locally on xampp and using Gmail SMTP plugin to get my contact form 7 to work. When I try sending a test email it fails, and i get this error message:
Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\xampp1\htdocs\WP\wp-content\plugins\gmail-smtp\PHPMailer\class.smtp.php line 369]
SMTP Error: Could not connect to SMTP host.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I changed the mail function settings in php.ini and sendmail configuration accordingly. Can you help me with what the problem might be here?
You are getting this error most likely because internally, PHPMailer is trying to establish a secure connection (SSL/HTTPS) and the SSL certificate verification is failing because it is most like a self-signed certificate (inside xampp just for development).
Try allowing insecure connections (without SSL encryption - at least during development) by using the suggested piece of code
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
As the document itself recommends against making these configurations globally in the php.ini file, you may want to revert them. And use the Run-time options instead (the code above).
Here is my smtp client for sending email from php with ssl socket https://github.com/breakermind/PhpMimeParser/blob/master/PhpSmtpSslSocketClient.php you can test with php
And here with php mailer example https://github.com/fxstar/PhpJsCss/blob/master/SMTPmail/send-phpmailer-smtp-ssl.php
Or here another example https://github.com/fxstar/PhpJsCss/blob/master/MailerPHP/smtp.php

PHP Codeigniter Mailgun - can't send email

I've already confirmed my custom domain and I'm always get this error:
554 Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings.
The following SMTP error was encountered: 554 Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings.
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Config:
$this->email->initialize(array(
'mailtype' => 'html',
'protocol' => 'smtp',
'smtp_timeout' => 30,
'smtp_host' => 'ssl://smtp.mailgun.org',
'smtp_port' => '465',
'smtp_user' => '***',
'smtp_pass' => '***'
));
What could be wrong? Try in both localhost / server - and the same error is shown. This is not credentials problem either cause I can see the logs on Mailgun dashboard.
Pretty sure that they changed their policy recently: "Without a credit card you are restricted to authorized recipients only."
You just need add CC to make it work. - They should put this message on the top of their registration page!!!
It's still free for first 10,000 though.
A bit annoying - but the solution is to add credit card to the account.
credit card need not be added. the error message clearly shows that no authorized recipients have been added. Mailgun allows 10,000 free emails for 30days, which can be used for testing (even from a local host) provided authorized email ids are added (upto 5). this can be done on the dashboard page. instructions given in the documentation. I have been testing out my mailer using a localhost (WAMP server) on 3 authorized email recipients that i've added. credit card is to be added only when the 10000 email quota is exceeded.

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.

Why does my online contact form produce a Warning and Fatal Error when after sending utilising my host's relay, but not with Google's?

I have recently migrated a web form online after testing in XAMPP using a Google SMTP relay and Swiftmailer. There has been absolutely no problems with the Google relay utilising my own inbox, however, when trying to switch to my hosting provider's (Siteground) recommended relay and instructions, also utilising a domain based email, my form is hanging on send, and I receive the following:
Warning: stream_socket_enable_crypto(): Peer certificate CN=`*.sgcpanel.com' did not match expected CN=`uk2.siteground.eu' in /home/tho/public_html/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 95
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Unable to connect with TLS encryption' in /home/tho/public_html/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php:289 Stack trace: #0 /home/tho/public_html/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand() #1 /home/tho/public_html/swiftmailer/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #2 /home/tho/public_html/sendmessage.php(30): Swift_Mailer->send(Object(Swift_Message)) #3 {main} thrown in /home/tho/public_html/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 289
Note that the email account itself is working perfectly. It is set up in Mac Mail, and sends and receives with no issues at all.
My hosting provider is trying, but I don't think they can understand what issue I'm having. I've ended up narrowing it down to the transport function. See my code from the PHP below:
Google (which works as expected):
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
->setUsername('foobar#googlemail.com')
->setPassword('APP GENERATED PASSWORD');
Hosting Provider (which does not work as expected):
$transport = Swift_SmtpTransport::newInstance('uk2.siteground.eu', 25, 'tls')
->setUsername('email#mydomain.com')
->setPassword('MY EMAIL PASSWORD');
The code seems ok to me, as it's only swapping out details. These were the settings provided by Siteground.
I've so far tried the following:
Changed the ports between 2525, 25, 587, and 465 without success;
Switched between TLS and SSL without success;
Changed my password trying various combinations without special
characters with no success;
Tried a Google search for all the permutations of 'Swiftmailer Siteground SMTP etc' but nothing has arisen.
Updated Swiftmailer to the latest version server side with no success;
I have raised further tickets, and they have updated the PHP server side for me. This now does not show an error, but just the number zero (ie. '0'). Also email is not being sent, but this is a separate issue for now.
From the error message it seems that the SSL certificate on the server uk2.siteground.eu does not include the correct hostname for the server, rather a wildcard for sgcpanel.com. The certificate on 587 it does not contain uk2.siteground.eu as a valid name for the server.
If you are using php 5.6 they changed the default to verify peer and peer names for certificates.
The proper fix would be for Siteground to add correct certificates to the server. You might override the checks with the newest version of SwiftMailer on github it seems.
The setStreamOptions added in september might solve your problems, but reduce security a bit by not checking if it is the correct server it is communicating with.
I'm not able to test it at the moment, but try:
$ssl_options = array(
'ssl' => array(
'verify_peer' => false,
'verfify_peer_name' => false,
),
);
$transport->setStreamOptions($ssl_options);
Or the array might be
$ssl_options = array(
'verify_peer' => false,
'verfify_peer_name' => false,
);
$transport->setStreamOptions($ssl_options);
More info:
http://php.net/manual/en/context.ssl.php
https://github.com/swiftmailer/swiftmailer/issues/571
The answer was provided by my host. They made some alterations to the PHP server side. At first there was no success, but after waiting an hour or so, this sorted the issue.
Well, maybe not sorted in an ideal sense, but at least as a workaround.

Postfix, MediaWiki, LAMP, Server won't send out emails

I'm not sure if the issue with with Postfix, MediaWiki, LAMP or what. Basically I configured an extension for MediaWiki for AccountRequest and it's supposed to send an email out to the user that created to give them login information. Emails aren't sent out. I figured it might be something to do with settings in localsettings.php but when I add the $wgSMTP array listed below but with my info I start getting [3b2f8024] 2015-11-24 20:19:31: Fatal exception of type "MWException" showing up on mediawiki.
$wgSMTP = array(
'host' => "mail.example.com", // could also be an IP address. Where the SMTP server is located
'IDHost' => "example.com", // Generally this will be the domain name of your website (aka mywiki.org)
'port' => 25, // Port to use when connecting to the SMTP server
'auth' => true, // Should we use SMTP authentication (true or false)
'username' => "my_user_name", // Username to use for SMTP authentication (if being used)
'password' => "my_password" // Password to use for SMTP authentication (if being used)
);
If I leave the localsettings.php settings as enabled and all that it will act like it works but users never get the email.
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "apache#10.00.000.000";
$wgPasswordSender = "apache#10.00.000.000";
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
Wondering of a good workaround for this or if someone can point me in the right direction to get this fixed that would be awesome. I've spent hours googling without any results. If my question isn't clear or you need more information please just ask.
Check that the SMTP server is actually reachable. With your $wgSMTP settings, do:
telnet mail.example.com 25
and see if you can connect. If not, either there is no SMTP server running there or there is a firewall. Double check the SMTP host and port, check instructions on how to open firewall in your distribution.

Categories