I am trying to create an email notification system with CI. The problem is the system on which I am working on has blocked gmail. So, i am unable to use the gmail SMTP. Now, I have to figure out a way to send emails with hotmail or any other SMTP services.
Here is my code which worked for gmail but now for hotmail
config/Email.php:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.live.com',
'smtp_port' => 587,
'smtp_user' => 'muttalebr#hotmail.com',
'smtp_pass' => 'XXXXXX',
'charset' => 'utf-8',
'newline' => "\r\n",
'crlf' => "\r\n",
'mailtype' => "html",
);
the actual function that calls the email.php and send the email:
function sends($from,$to,$send,$user){
$link=base_url()."index.php/anonymouscoll/cmembersarea/".$user;
$emailmessage="Hello $to,<br />You have a new Gift from $from.<br />Click on the link:<a href=$link>$link</a> to check your gift.<br /><br /><br />Best Regards<br />Online Communication.";
$this->load->library('email');
$this->email->from('muttalebr#hotmail.com','Gift File');
$this->email->to($send);
$this->email->subject('You have a new Gift');
$this->email->message($emailmessage);
if($this->email->send()){
echo "Email sent";
}
else{
show_error($this->email->print_debugger());
}
Each time i call the ‘sends’ function i get the below error:
Severity: Warning
Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Filename: libraries/Email.php
Line Number: 1673
and
Severity: Warning
Message: fsockopen() [function.fsockopen]: Failed to enable crypto
Filename: libraries/Email.php
Line Number: 1673
I have also tried with
‘smtp_host’ => ‘sslv2://smtp.live.com’,
but it just wont work on my local machine.
I am using windows 7 on my local machine and windows Xp for the system I will use the application[the one which blocked gmail]. I tried with both XAMPP ver 1.8.1 and WAMPP ver 2.2
Looking forward for your responses
~muttalebm
The error because you didn't enable SSL in your php.info file. SO search how to enable to it . Otherwise you can look into my answer to the question in the below link which is same liek this. I faced this error when i am doing and i resolved it.
Reference Link
Which version of PHP are you using?
There is apparently a bug in fsockopen ssl in some versions:
https://bugs.php.net/bug.php?id=54511
Related
I've been following the Laravel Mail docs https://laravel.com/docs/5.4/mail to send email via a SparkPost account. When I try and send I'm getting
ClientException
Client error: `POST https://api.sparkpost.com/api/v1/transmissions` resulted in a `401 Unauthorized` response:
{"errors": [ {"message": "Unauthorized."} ]}
As per the docs I've got the sparkpost key in config/services.php and though the docs don't mention anything about it (why not!?) a bit of Googling convinced me to set the mail driver etc. in my .env file. I then have a web route to check the config being used,
Route::get('test', function()
{
dd(Config::get('mail'));
});
which gives
array:9 [▼
"driver" => "sparkpost"
"host" => "smtp.sparkpostmail.com"
"port" => "587"
"from" => array:2 [▶]
"encryption" => "tls"
"username" => "my-sparkpost-account-login-email-address"
"password" => "my-sparkpost-account-login-password"
"sendmail" => "/usr/sbin/sendmail -bs"
"markdown" => array:2 [▶]
]
I actually want to use a mailable and views which I've set up, but just to test the sending I bypassed these and set the following route to test:
Route::get('/sparkpost', function () {
Mail::send('emails.test', [], function ($message) {
$message
->from('marketing#my-sparkpost-sending-domain.com', 'Me')
->to('my-email-address', 'My-Name')
->subject('A Test Email');
});
});
which got the error at the top (testing with my mailables and views gave the exact same error which makes me think they are correctly set up - assuming the above test route is correct).
The on thing I'm wondering about is I'm testing on my local machine, so test URL is http://localhost/seg/public/sparkpost - I'm wondering if this is tripping SparkPost up (i.e. do I have to actually be sending from a server running at the same domain as the sending domain configured in sparkpost, or is it just the sending address in the email that has to match?)
Thanks for any suggestions!
if you use smtp driver,
You need go to Account > SMTP Relay to get credentials for SMTP,
it's not your sparkpost account credentials.
if you use sparkpost driver,
you need put api key of sparkpost into config/services.php, there is no need to input smtp username and password if you use sparkpost driver
I have been trying to integrate stripe payment in laravel.
But when i try to create a customer in stripe,it won't created.
Here is my code,
try
{
$customer = \Stripe\Customer::create(array(
'email' => $this->user_email,
'card' => $this->stripe_token
));
echo "<pre>";
print_r($customer);exit;
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amountstripe,
'currency' => 'EUR'
));
}
I got an error message like,
Could not connect to Stripe (https://api.stripe.com/v1/customers). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support#stripe.com.
(Network error [errno 6]: Could not resolve host: api.stripe.com)
How can i resolve this problem?
This is not an error with Laravel or Stripe, but "simply" a network error. Your server cannot send requests to Stripe's API because it cannot resolve the hostname api.stripe.com to an IP address.
You'd need to get in touch with your network administrator or hosting provider and ask them to check the connectivity between your server and Stripe's. The following script may be helpful in diagnosing the issue: https://github.com/stripe/stripe-reachability#stripe-reachability
i have some probleme using swiftmailer for setting my confirmation email, normaly everything is set well, but the mail is not sent, and i have my user in my database (but enable is set to 0 of course).
Since i don't have errors show by symfony i suppose it's my gmail account that blocked them, but i already set it to allow other application to use it as a "server", and i have a page that use swiftmailer to send normal mail, and it work fine.
i'm lost, thanks for your future help
My config.yml :
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
encryption: ssl
fos_user:
db_driver: orm
firewall_name: main
user_class: UserBundle\Entity\User
service:
mailer: fos_user.mailer.default
registration:
confirmation:
enabled: true
from_email:
address: maxime.duvey#gmail.com
sender_name: Registration mail
My config.yml :
mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: maxime.duvey#gmail.com
mailer_password: XXXXXXXXXXX
i'm really lost, i don't understand why it don't work
It might be because you have to turn on "Less Secure Apps" as gmail allows doesn't allow you to access logins unless it is a secure app that they provide. This can be found in you google admin console.
See the link here for more info
I had the same problem when using PHPMailer.
However if you do decide to turn it on, it is not recommended.
They mention this in the link provided.
now that i think of it, it's maybe my manner to add a new user to my database :
my controler :
$userregister = new User();
$formregister = $this->get('form.factory')->createBuilder(FormType::class, $userregister);
$formregister
->add('firstname', TextType::class)
->add('lastname', TextType::class)
->add('email', EmailType::class)
->add('phonehome', NumberType::class)
->add('phoneportable', NumberType::class)
->add('username', TextType::class)
//->add('Password', PasswordType::class)
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
))
->add('submit', SubmitType::class);
$form = $formregister->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($userregister);
$em->flush();
$request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.');
return $this->redirect($this->generateUrl('Contact_Action', array('id' => $userregister->getId())));
}
return $this->render('register.html.twig', array('form'=>$form->createView()));
and my twig :
{{ form(form) }}
i'm not sure, maybe
I send email on localhost but doesnt work same settings on server(digitalocean+serverpilot).
php's open ssl support is enabled.
php get "Message: fsockopen(): unable to connect to
ssl://smtp.yandex.com.tr:465 (Connection timed out)
codeigniter framework get :
The following SMTP error was encountered: 110 Connection timed out
Unable to send email using PHP SMTP. Your server might not be
configured to send mail using this method.
my code is:
$config = Array('protocol' => 'smtp','smtp_host' => 'ssl://smtp.yandex.com.tr','smtp_port' => 465, 'smtp_user' => 'info#mydomain.com','smtp_pass' => 'mypass','mailtype' => 'html', 'charset' => 'utf-8');
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('info#mydomain.com', 'test.com');
$this->email->to('testing#yandex.com');
$this->email->subject('test');
$this->email->message('test body');
$this->email->send();
echo $this->email->print_debugger();
nslookup smtp.yandex.com:
Server: 2001:4860:4860::8844 Address: 2001:4860:4860::8844#53
Non-authoritative answer: smtp.yandex.com canonical name =
smtp.yandex.ru. Name: smtp.yandex.ru Address: 93.158.134.38
Name: smtp.yandex.ru Address: 87.250.250.38 Name: smtp.yandex.ru
Address: 213.180.204.38 Name: smtp.yandex.ru Address: 213.180.193.38
Name: smtp.yandex.ru Address: 77.88.21.38
and telnet request is work.
Your outgoing connection may be blocked by a firewall.
Use tool like tcptraceroute to locate the problem.
I have tried everything I can think of. I have tried with all authentication types I can think of.
here are my settings
delivery_method :smtp, {
:address => "xxxxxxxxx.com",
:port => port,
:domain => 'xxxxxx.com',
:user_name => 'username',
:password => "passworde",
:authentication => 'plain',
:enable_starttls_auto => true }
here is my error if I use port 25 (I believe this to be the correct port)
c:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:960:in `check_auth_response': 504 5.7.4 Unrecognized authentication type (Net::SMTPAuthenticationError)
here is my error if I use port 587
c:/Ruby193/lib/ruby/1.9.1/openssl/ssl-internal.rb:121:in `post_connection_check': hostname does not match the server certificate (OpenSSL::SSL::SSLError)
The hash you're passing should have :plain defined as a symbol rather than a string per the ActionMailer::Base docs. The server is definitely responding on port 25 (that 504 5.7.4 Unrecognized authentication type error is from the server) so stick with that port.
It's also probably that plain auth is disabled on your server. Check out Cannot get ActionMailer working with MS Exchange via SMTP for more info.