Miva Merchant Modules and Development
Want to start an online store? We work with you from start to finish, from commerce platform to design to SEO.
Experience counts, and we have a lot.

EMAIL: Simple Module MivaScript Function to Send Email

Scot Ranney • August 15, 2024


<MIVA STANDARDOUTPUTLEVEL = "compresswhitespace,text,html">
<MvCAPTURE VARIABLE = "l.email:message">
	This will be a text email message.
	<MvEVAL EXPR = "{ asciichar(10) }">
	Another line in the email message.
</MvCAPTURE>	 
<MIVA STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.email:subject" VALUE = "{ 'A subject for The Email' }" />
<MvASSIGN NAME = "l.email:to" VALUE = "{ 'someonesemail@domain.com' }" />   
<MvASSIGN NAME = "l.ok" VALUE = "{ send_email(l.email) }" />
<MvFUNCTION NAME = "send_email" PARAMETERS = "email" STANDARDOUTPUTLEVEL="">	
	<MvASSIGN NAME = "l.lf_single" VALUE = "{ asciichar(10) }" />
	<MvASSIGN NAME = "l.lf_double" VALUE = "{ asciichar(10) $ asciichar(10) }" />
	<MvIF EXPR = "{ NOT l.email:from }">
		<MvASSIGN NAME = "l.email:from" VALUE = "{ g.store:email }" />
		<MvASSIGN NAME = "l.email:from_name" VALUE = "{ g.store:name }" />		
	</MvIF>
	<MvIF EXPR = "{ l.headers }">
		<MvCAPTURE VARIABLE = "l.headers_parsed">
			<MvFOREACH ITERATOR = "l.header" INDEX = "l.headerpos" ARRAY = "l.headers">
				<MvEVAL EXPR = "{ l.header }">
				<MvEVAL EXPR = "{ l.lf_single }">
			</MvFOREACH>
		</MvCAPTURE>
		<MvASSIGN NAME = "l.message" VALUE = "{ l.message $ 'ShipNetwork Return Headers: ' $ l.lf_double $ l.headers_parsed $ l.lf_double }" />		
	</MvIF>
	<MvASSIGN NAME = "l.mailok" VALUE = "{ [ g.Module_Library_Utilities ].sendemail(l.email:to,l.email:from,l.nulll,l.email:subject,l.email:headers,l.email:message) }" />
	<MvFUNCRETURN VALUE = "{ l.mailok }">
</MvFUNCTION>

This calls the miva merchant api text email function so it can only be used from a module or template.


https://www.scotsscripts.com/mvblog/email-simple-module-mivascript-function-to-send-email.html

mvkb_module mvkb_email mvkb_mivascript