Text formatting issues when sending the contents of a record with the @mail function

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-04 19:02

Hi everyone.

When I send the contents of a textarea field with the @mail function, the message arrives at the recipient with incorrect formatting.

For example, if the textarea field "status_request" contains the text:

“04/08/2020 h. 20:06:
iI tuo attestato è stato generato ed è disponibile nell'area agenda-richiesta attestato.
Ti basterà cliccare sulla tua richiesta per visualizzare il dettaglio della stessa e il pulsante per stampare e scaricare l'attestato.”

In the email received by the recipient, the text looks like this: (In the result, I put the critical parts in bold)

“04/08/2020 h. 20:06:\r\niI tuo attestato Ú stato generato ed Ú disponibile nell\'area agenda-richiesta attestato.\r\nTi basterà cliccare sulla tua richiesta per visualizzare il dettaglio della stessa e il pulsante per stampare e scaricare l\'attestato."

this is my code:

Code: Select all

@mail(
		"[email protected], {$data['recapito_email']}",
		
		// subject
		"Sulla Buona Strada - La tua richiesta di attestato per l'attività $titolo_evento [Partecipante: {$data['nome']} {$data['cognome']}] è stata aggiornata",
		
		// message
		"Abbiamo aggiornato la tua richiesta di attestato per l'attività: $titolo_evento.\n\n".
		
		"Di seguito le informazioni sullo stato della tua richiesta:\n".
		"{$data['stato_richiesta']}\n\n\n".
Can I add something in my code to specify the character set and to ensure that line wraps are respected rather than replaced with symbols?

Thanks for your help!

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by a.gneady » 2020-08-05 16:06

Try using the sendmail() function instead. It allows you to use HTML in the message, which allows using HTML entities .. So, instead of using è, you can use the HTML entity representation è ... For other HTML entities, see https://www.w3schools.com/charsets/ref_ ... ties_e.asp

Usage of sendmail:

Code: Select all

sendmail([
   'to' => '[email protected]',
   'name' => 'Sender name',
   'subject' => 'Subject of email here',
   'message' => 'Email message. <b>HTML tags</b> allowed. Also HTML entities like &#232;'
]);
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-05 16:20

Thank you for your answer Ahmed!

The problem is that my email message must contain the text filled in a specific text area field of the record.

So is impossible to pretend that user that compile the form write for example some code instead of any è, à ì, ù....

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-06 11:33

as I said the problem is that I have to automatically send the contents of some fields of the record. Is there a way to indicate the character encoding before indicating in the code the database field to be reported in the message?
Could you give an example with the code to generate a message with utf-8 encoding and insert the content of the "my_table_field" field in the message body?
THANK YOU!
Fabiano

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by a.gneady » 2020-08-06 13:03

OK, try using the AppGini function to_utf8() to encode the message:

Code: Select all

'message' => to_utf8($data['fieldname']),
Change fieldname above to the actual field name.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-07 05:48

Hi and thanks for the help.
There are still a lot of things I don't know about the sendmail function. Is it an appgini function or a "native" php function? (excuse my inexperienced language).
I did some research on the web with poor results.
Could you (or someone else forum members) tell me where to find more information on sendmail?

Thank you so much!

Fabiano

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by a.gneady » 2020-08-09 14:31

It's an AppGini function, defined in admin/incFunctions.php. So, you won't find it documented elsewhere, but you can view its source in that file if you wish to.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-13 19:38

Thank you!
I will check that file!
Fabiano

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: Text formatting issues when sending the contents of a record with the @mail function

Post by fgazza » 2020-08-13 19:39

Thank you!
I will check that file!
Fabiano

Post Reply