Jump to content

sending EMail Problem


Recommended Posts

I'm trying to create a custom form (module) that a customer would fill up, and then send email , current I just used to input form and a submit button, when click there is no error,but no email sent or receive.


**Note: this is similar to send a friend module (but I am planning to ad more input form)


this  is my display.tpl


<script type="text/javascript">
var name1 = $('#name1').val();
var email = $('#email').val();
if (name1 && email)
type: "POST",
headers: {"cache-control": "no-cache"},
data: {action: 'sendQuote', name1:name1, email:email},
dataType: "json",
success: function(result){
This is Lumberyard
<form method="post" action="{request_uri}" class="lmbr">
{l s="Name"} <input id="name1" name="name1" type="text" name="name1" value="" size="14" />
{l s="Name"} <input id="email" name="email" type="text" name="email" value="" size="20" />
<input id="sendQuote" class="button" name="sendQuote" type="submit" value="Send Quotation" />
and this is my quotation ajax
$module = new MyModule();
if (Tools::getValue('action') == 'sendQuote')
$name1 = Tools::getValue('name1');
$email = Tools::getValue('email');
$name1 = 'Name1';
$email = 'email';
$templateVars = array(
'{name1}' => Tools::safeOutput($name1),
'{email}' => Tools::safeOutput($email)
if (!Mail::Send((int)$module->context->cookie->id_lang,
$templateVars, $email,
($module->context->cookie->email ? $module->context->cookie->email : null),
I am also attaching my complete module for your reference


Share this post

Link to post
Share on other sites

You do not need init.php since it is depricated. The syntax for sending mails:


$mail = Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')),
         {smartyname} => {value}
       "{receivername}", "{sender}", "{sendername}", "{attachments}", "{SMTP mode (true/false)}", "{template directory}");
Also you can look at the returnvalue of the mail variable ($mail = Mail::send).
Also try and test if your shop can send mail. Make a test order and see if you get feedback
  • Like 1

Share this post

Link to post
Share on other sites

thanks for the reply, I will check this out, but somehow I have a related issue, it seems that when posting via javascript, it is having an error like

POST: <url> 404 (not Found)


from what i have understand on error,it cannot find the file(php file),but when i check the url, where my javascript will supposed to POST , the file is there

Share this post

Link to post
Share on other sites

Thanks for helping out,


I manage to solve Post method problem from javascript by correcting the right path where my php file is located like " url : '{$base_dir}modules/modulename/file-name.php' "

and using the Send mail syntax that "jsmit2" posted I was able to send an email.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More