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.
Related
I'm generating mailto links in support emails to make it easier to reply to customers directly from within Gmail. A typical mailto link might look like this:
mailto:customer#example.com?subject=Re%3A%20Feedback%20%20%20%5B1620394320%5D&body=%0A%0A%3E%20Original%20message%20from%20customer%40example.com%2C%202021-05-07%3A%0A%3E%20Customer%20message%20here
This works, except the original message is interpreted literally, even though the lines start with > (which I had expected to be interpreted as a quote of a previous message).
So the reply email would literally look like this for the customer:
> Original message from customer#example.com, 2021-05-07:
> Customer message here
What I want is for the lines starting with > to be treated as a quote of the original message, just like when replying to an email from any email client.
Is it possible to make Gmail do this with a body included in a mailto link?
I am generating emails with Google Apps Script and the emails are being sent with line breaks in weird places.
Here is my code
function sendEmail(){
var name = "MyName"
var body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." +
"\n\nNOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
GmailApp.sendEmail("MyEmail#gmail.com", "You've been challenged!", body)
}
You'll notice that it is also putting the text of the first section of the body in a purple color. I also don't know why this is happening but my priority is to stop the line breaks from being put where they shouldn't be.
Google 'Stacks' emails. Say for example I send you an email. Then you reply and I reply again. It stacks them all into one line in your inbox.
Any identical paragraphs in the emails are made purple. Only you see the purple.
If you delete all of the emails out of your inbox and test again, you should notice it in black.
Also, you have code to create two new lines. '\n' x2. You're essentially creating a new paragraph, do you just want a new line to begin instead? If so delete 1x '\n'. Sorry if I'm not understanding your issue.
If you were to insert the body as html and use paragraph tags you would likely be able to achieve the results you are pursuing.
I am on mobile and don't know how to get resource links to prove the above sorry.
Edit: I would make the following change:
body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." + "\n\n" + "NOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
Your code is including the body as plain text so it is automatically cropped at certain line length. Below some questions about the same "problem"
Gmail API - plaintext word wrapping
Why isn't Gmail using quoted-printable encoding?
If you want to have more control about how the message content looks on Gmail, besides sending the content as plain text sent it as HTML. For doing this use
sendemail(recipient,subject,body,options)
Related questions about using the above method:
Sending an email in HTML and plain with a Gmail Apps Script
I want to get the email address that i mention in the image.The email i received from my clients and i am using applescripting and
i want to use that email as recipient.I will send auto mail to this email address.
Thank You.
The concrete solution depends strongly on the HTML text.
You got two options:
Get the source of the message, extract the HTML part, use an HTML parser to get the address or convert the HTML text to plain text with textutil.
Get the content of the message – which is plain text – check all paragraphs for email parts and use regex or sed or text item delimiters to extract the address.
i am read a email using Web-methods services and facing problem, Web-methods reading HTML format email as a plain text and giving us HTML. so, i like to set content type as plain text through mail-to function. and i am using this syntax but not working:
mailto:xxxxxxx#sapient.com?Content-type=text/plain"
problem solved, solution: we can add a property on exchange server for particular email id that this email id will get email in text/plain form only. so now i am sending a HTML email then exchange server convert it as a plain text email.
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.