I currently have a contact form on my website which sends off an email notification upon submission. It is working perfectly on my end and even when I send it externally to friends as a test they are receiving it.
My client however, who is in France, can't seem to receive this email at all and I have no idea why. Is there anything I need to do to ensure that they receive it? I thought it was something on their end but they're absolutely adamant that it's not and that it's a problem with my code. I have tried different email addresses for them with different domains and still no luck!
$this->load->library('parser');
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$this->load->library('email');
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'message' => $this->input->post('message')
);
$body = $this->parser->parse('html_email', $data, true);
$this->email->from('test#test.com', 'Duparc');
$this->email->to('test#test.com');
$this->email->subject('Test Email');
$this->email->message($body);
$this->email->send();
In my opinion the problem does not originate from CodeIgniter. Assuming the mail did not went into a spam box, your customer's provider is probably dismissing your message for some other reason. One reason I can immediately think of is that you are probably trying to send a message from a domain (e.g. test.com) you're not allowed from. My advise is starting to try sending an email with another tool to your french customer (any sendmail or postfix client tool) and to see if he do receive it.
If that succeeds, then the problem probably comes from your forged email (therefore try using a valid domain name). Sometimes removing it completely will work too (it might then be replaced by the external IP).
If not, then the problem comes from your web server's config. I had this problem using postfix where I had to explicitly set the "General Options" > "What domain to use in outbound mail" configuration option to my domain name in order to be accepted by a capricious server which silently dismissed our mail.
If nothing is working, you might also use another mail server which might luckily fix the issue. Here is the code I used to force CodeIgniter using sendmail instead:
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$this->email->initialize($config);
Related
After I changed my shared host, I have problem with Forgot password link. In my app all sections need to send email work fine but when I pressed forgot password button I got success alert that link sent to your email but when I checked my mails it was empty!!(app doesn't send link)
I checked all my logs in app and host there weren't any error.
I use default Laravel settings.(Laravel 7).
In .env file add new variable called MAIL_FROM_ADDRESS=your_smtp_from_mail_id . you have to set MAIL_FROM_ADDRESS to valid SMTP from_mail email id. sometimes in the .env file, this variable doesn't exist. if it is not set manually; when sending mail it is picking up a default mail id which is hello#example.com. please have look here config/mail.php
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
i think this should work !
This worked for me.
Need help setting up Mail on my Laravel application.
My .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=*****#*****.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
This returns the following error :
Expected response code 250 but got code "", with message ""
I had the same problem and it turns out Office 365 doesn't let you use a different from setting in your mail sending function than the one you use in your .env file.
I wanted to set the from name and email address according to whatever data was coming in via the request of a form submission as to capture them in the CRM system and it threw that same exception. Not sure if this helps you, but this was how I solved my problem.
Here's my code in the controller as an example:
$data = [
'name' => $request->get('name'),
'surname' => $request->get('surname'),
'email' => $request->get('email'),
'phone' => $request->get('phone'),
'subject' => $request->get('message-subject')
];
$from = $data['name'] . ' ' . $data['surname'];
Mail::send('mail.mymail', compact('data'), function($message) use ($request, $data, $from) {
$message->to('example#companyiworkfor.com', 'Some Company I Work For')->subject('Website Contact Form');
$message->from($data['email'], $from);
// Office 365 won't let you use a different from address here,so use same email as per your .env
});
We were getting the same error message in one of our customer's internal tool, which runs on Symfony 3 and Swiftmailer v5.4.4.
After some debugging, I found out that there was a previous exception thrown by Swiftmailer. The reason was the response from smtp.office365.com:
421 4.7.66 TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls. [AM6PR02CA0020.eurprd02.prod.outlook.com]
Microsoft dropped support for TLS 1.0 und 1.1. After some research I found this github issue:
This commit (4c4b333) introduced TLS 1.1 / 1.2 support, but didn't make it to any release yet. Unfortunately all Swiftmailer users (besides the ones using recent dev-master) are tied to TLS 1.0, which starts to give issues
In one of the comments #fabpot replied that they've backported the bugfix to Swiftmailer 5. It landed in release 5.4.10.
After upgrading Swiftmailer, the mailing worked again.
I'm trying to create a simple contact form but unfortunately having some trouble getting the flash data to show once redirected.
Mail::send('emails.contact', $data, function($message) {
$message->to('support#domain.com', Input::get('name'))
->subject('Contact Form');
});
Mail::send('emails.received', $data, function($message) {
$message->to(Input::get('email'), 'Website Owner')
->subject('Message received');
});
return Redirect::to('contact')->with('messages', 'Thank you, your message has been received');
When form is submitted, it successfully sends two emails. One to the website admin, the other to the person who submitted the form.
Problem being, once redirected I expect to see the flash data which I don't. I am currently using var_dump(Session::all()) to show data.
Saying this, when I remove one or both Mail functions, the flash data displays correct on submit.
Furthermore, the above script is working on a local build but not on my development server.
I am very stuck and have been looking for a solution for a few hours, any insight will be much appreciated!
I am trying to send an email to customers with html form.
here is the controller file.
$email = 'jc2332#gmail.com';
$title = 'Introducing our new product!';
$msg = $this->load->view('admin/email_new_version', '', true);
$config['mailtype'] = 'html';
$this->load->library('email', $config);
$this->email->from('cs#example.com', 'company');
$this->email->to($email);
$this->email->subject($title);
$this->email->message($msg);
$this->email->send();
It looks fine for me, but html doesn't work when I receive the mail.
Try to use this configuration and try to initialize the email library in a separated command:
$this->load->library('email');
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
This should work!
The code looks fine. What do you mean when you say "html doesn't work when I receive the mail"? What kind of environment do you host it on?
Let's try simple debugging:
1) Check if the template is being loaded:
echo $this->load->view('admin/email_new_version', '', true);
die();
2) Validate your HTML.
3) Try setting different values in crlf, newline and charset preferences.
go system/libraries/email.php
check $mailtype vairable value
set $mailtype='html'
I think main area to focus on is whether or not you are using a local setup like wamp/lamp or any other local server installation where you are using a regular adsl connection with your ports not serving outside your lan.
You need to host your project in a hosting provider or open your ports to be able to serve to internet (the latter is not recommended without taking security precautions and also without having a mail server running this should not work) in order for email->send() function to work properly
We send emails in plain text from PHP using CodeIgniter (v1.7) and also PHPMailer (v5.1). Current production setup uses a cheapie SMTP relay, plan is to switch to a CritSend or SendGrid. We are testing the options now from a Rackspace Cloud server.
When we use SendGrid SMTP all "\r\n" newlines in the emials end up being doubled up, so end up as "\r\n\r\n".
All works fine when using CritSend SMTP and also two other SMTP servers.
SendGrid tech support don't think it is anything to do with their system, but have heard of another client with the same issue and apparently it got solved with a config change on the client's side.
Anyone experienced this?
This isn't critical for us as CritSend works well and seems as good as SendGrid on features, so we will go with them. BUT being a curious type, I just can't let this go :-)
Usual setup: PHP script -> sendmail/Postfix -> external SMTP relay -> ....
To test the different SMTP relays I change the postfix config, only SendGrid gives the extra newlines all other SMTP options work fine. If I dump the email via CodeIgniter email class debug function it looks fine before it goes to postfix.
Alternate setup: PHP script (either CI mail class or PHPMialer) -> external SMTP relay -> ....
To test the different SMTP relays I change the SMTP settings in the CI email config or PHPMialer config. Only SendGrid gives the extra newlines all other SMTP options work fine.
There aren't all that many options to play with as far as I can see. I tried "utf-8" and "ISO-something or other", all newlines on our side are "\r\n"...... seesm like some very obscure bug somewhere.
Any ideas?
OK, a bit more experimenting and these settings make plain text emails go trough SendGrid nicely from PHPMailer:
$mailer->CharSet = "utf-8";
$mailer->LE = "\r\n";
$mailer->Encoding = "quoted-printable";
$mailer->WordWrap = 80;
The "quoted-printable" part is the key.
What worked for me was using actual line-breaks in the PHP text as follows:
// Prepare email
$email = array(
'api_user' => App::emailAPIUser(),
'api_key' => App::emailAPIPwd(),
'to' => $email,
'subject' => 'Thank you for entering ' . App::name(),
'html' => $email_body,
'text' => '
Thank you for entering Competition.
You are now in the running to WIN your prices valued at $6000.
Winners will be notified of their status by the 14th February 2012.
Good luck!',
'from' => 'competitions#company.com'
);