CakePHP emails being sent as text instead of html - email

We recently switched to a new server and now when we send out our email blasts through cakePHP, users who were receiving email as html before are now getting them as code. Any thoughts?

You can configure the format in your controller:
//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'both'; // because we like to send pretty mail
// more code here
$this->Email->send();
If this was triggered by a server move, it's possible that you are missing a file rather than a line of code. In that, case, make sure you have layouts setup for both types of email. Here is the file structure to check:
app/views/layouts/email/
html/
default.ctp
text/
default.ctp
For more from the cookbook:
http://book.cakephp.org/view/1286/Sending-a-basic-message

Related

Laravel save a copy of the email on storage

I'm sending emails in Laravel with mandrill but I also want to save a copy of the email on the storage also (like mailoutput but in my own log folder)
Do you have any idea how to do that?
Thank you
Though you can log mails in Laravel, it seems that emails will not actually be sent at the same time.
A simple solution would be to log emails yourself:
Find where you send emails and add customized logging statements.
Mail::send('emails.welcome', array('key' => 'value'), function($message)
{
$message->to('foo#example.com', 'John Smith')->subject('Welcome!');
Log::info('You email content and receivers here');
});

Magento print transcational emali before mail send

is it possible to print transaction email body before email send? I just want to see how to display layout after display value in transactional email.
All Magento emails are send through this method: Mage_Core_Model_Email_Template::send().
Here is how I usually check my e-mail templates. In the method mentioned above, right after these lines:
if($this->isPlain()) {
$mail->setBodyText($text);
} else {
$mail->setBodyHTML($text);
}
I add this:
echo $text;exit;
instead of sending an e-mail it just prints it in the browser.
Don't forget to remove this line after you're done testing.
If you want to use the this in a live environment and save all the send e-mails you will have to do a more elaborate thing, live overriding the class, and not stopping the script at all, but you can do all this in the same place.

How to get the received email with spaces in CAKEPHP?

In my cakephp website i have a controller which handles a simple contact form. But i have a problem! If in the contact_controller.php code i use:
$this->Email->send($this->data['Contact']['message']);
i receive the email in my mail box with linebreaks like the user wrote the message. But if i use:
$this->Email->send();
and create an html template to get the variables that i want to receive in mail, i will receive the same with no linebreaks.
How i can fix that?
Which one do you want? In the first case you send a plain text email, so you will have your line breaks in place.
In the second place you send HTML e-mail, where line breaks are in place, but simply ignored.
So either keep sending mails plain text or use nl2br() function on the body for html output.

How to send form contents anonymously via email

How do you send the content of a website form to an email address without disclosing the email address to the user.
Thanks!
PS: If at all possible, I would like this to be in HTML JavaScript Ok, anything I guess.
Not possible. You can however put a "fake" from header in the mail. You'll only risk it to end up in the junk folder.
HTML doesn't provide any functionality to send mails. You'll really need to do this in the server side. How exactly to do this depends on the server side programming language in question. In PHP for example, you have the mail() function. In Java you have the JavaMail API. And so on.
Regardless of the language used, you'll need a SMTP server as well. It's the one responsible for actually sending the mail. You can use the one from your ISP or a public email provider (Gmail, Yahoo, etc), but you'll be forced to use your account name in the from header. You can also register a domain with a mailbox and just register something like noreply#example.com and use this to send mails from.
Update: JavaScript can't send mails as well. Like HTML it's a client side language. You'll need to do it with a server side language. All JavaScript can do is to dump the entire page content back to the server side. jQuery may be useful in this:
$.post('/your-server-side-script-url', { body: $('body').html(); });
with (PHP targeted example)
$to = 'to#example.com';
$subject = 'Page contents';
$body = $_POST['body']
$headers = prepare_mail_headers();
mail($to, $subject, $body, $headers);
Update 2: if you actually want to hide the to header in the mail, then you'll need to use the bcc (Blind Carbon Copy) instead. This way the recipient addres(ses) will be undisclosed. Only the from, to, cc stays visible.
If you mean doing so on a client side, using mailto: link - you can not.
If you mean any way, yes - you submit the form contents back to your server, and have your back end script send the email.
You can do the form in HTML, but the posting will need to be done in a script. Even if you don't expose the email address, the script can be used to spam that email address. This is why you see captcha being used in such cases.
There are scripts available for most languages. Check to make sure their are no known security problems for the scripts. The original Matt's script in perl had problems, and the Perl community created a more secure version.

Sending form without mail client

everubody! can you help me with my trouble? I'm trying to create form for filling resume. User should not use mail client to submit form. How can I realize this idea on javascript or PHP?
First: You need a server based script. Without any server interaction, no mail can be sent.
PHP has a mail() function and it works very well, if your server administrator enabled it.
Very simple example:
<?php
// The message
$message = "Line 1\nLine 2\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('caffeinated#example.com', 'My Subject', $message);
?>
If mail() is disabled, you need to connect a SMTP server with correct credentials and then you can send mails via this connection.
This function is implemented in the emailer module of phpBB2 e.g.
Good luck!
If the form as a file upload... You can just upload the cv to the webserver and then use your application to send an Email using your account.