How To Send An Email

Hi,



I want to send an email to the mail id's that were taken from a textbox.

Anyone please help me how to send the email, It is a high priority for me.







Regards,

Satya.

[quote name='satya1328' timestamp='1431685098' post='214480']

I want to send an email to the mail id's that were taken from a textbox.

Anyone please help me how to send the email, It is a high priority for me.

[/quote]



Please clarify your request

[quote name='eComLabs' timestamp='1431686616' post='214486']

Please clarify your request

[/quote]





Hi,



I want to send a referal link to register in the website for some mail-id (for eg., test@sample.com). This mail-id has been captured from a textbox.

When the receiver clicks on that referal link, He has to redirect to Registration page of the website.



Please help me how to send the referal link to the corresponding mail-id that was entered in the textbox.

I am afraid, it is required to examine your custom code to answer on your question

[quote name='eComLabs' timestamp='1431692390' post='214509'] I am afraid, it is required to examine your custom code to answer on your question [/quote]



Here is my custom code.



function fn_referal($referal_email, $referal_user_id) {



$db_querry = db_get_row(“SELECT * FROM ?:referal_links WHERE referal_email LIKE '%$referal_email%'”);

if(!empty($db_querry)) {

return false;

}

else {

$referal_code = md5(uniqid());

$referal_date = date('Y-m-d H:i:s');

$firstname = db_get_field(“SELECT firstname from ?:users WHERE user_id = '$referal_user_id'”);

$db_que = db_query(“INSERT INTO ?:referal_links (referal_code, referal_email, referar_user_id, referal_date, referal_status, referal_link_count) VALUES('$referal_code', '$referal_email', '$referal_user_id', '$referal_date', 'N', '1')”);

return true;

}

}



Now i want to send an email to the “referal_email” after inserting the data into the ?:referal_links table.

[list]

[]

I am getting the “$referal_email” value from the form and “$referal_user_id” is the $_SESSION['auth']['user_id'] value.

[
]

$referal_code is a unique id that was sending to the receiver(referal_email).

[]

$referal_date is the date when the link is sending.

[
]

$firstname is the firstname from the ?:users table.

[/list]



Regards,

Satya.

Hi ,

Anybody please help me to fix the issue. It's a high priority to me.

Thanks in advance.



Regards,

Satya.

Search the 'functions' directory for 'Mailer' for examples of how the Mailer class is used. You will have to provide a template, template variables, etc. But if it's just simple text, you might want to just use the PHP mail function instead.

[quote name='satya1328' timestamp='1431775171' post='214591'] Hi , Anybody please help me to fix the issue. It's a high priority to me. Thanks in advance. Regards, Satya. [/quote]



For example, please check the fn_send_usergroup_status_notification function in the app/functionc/fn.users.php file

[quote name='eComLabs' timestamp='1431938981' post='214699']

For example, please check the fn_send_usergroup_status_notification function in the app/functionc/fn.users.php file

[/quote][quote name='tbirnseth' timestamp='1431805390' post='214614']

Search the 'functions' directory for 'Mailer' for examples of how the Mailer class is used. You will have to provide a template, template variables, etc. But if it's just simple text, you might want to just use the PHP mail function instead.

[/quote]



Hi,

Thanks for your help. As based on your suggestion, I written the following code,





$result = Mailer::sendMail(array(

'to' => $referal_email,

'from' => 'company_orders_department',

'data' => array(

'access_key' => $referal_key,



),

'tpl' => 'addons/communities/referal_link.tpl',

),'C');

if ($result) {

fn_set_notification('N', __('notice'), __('Referal Link Sent '));

}

else {

fn_set_notification('E', __('error'), __('Referal Link Not Sent'));

}



I also created the “referal_link.tpl” in the following file path,

design\themes\responsive\mail\templates\addons\communities

still the mail is not sent.



It was working well if any other predefined addon file path is given.



Please suggest me, If any code modifications is necessary with my code.



Regards,

Satya.

Did you add the following code at the beginning of the file?



use Tygh\Mailer;

[quote name='eComLabs' timestamp='1432033809' post='214918']

Did you add the following code at the beginning of the file?



use Tygh\Mailer;


[/quote]



Yes i added it…

[quote name='eComLabs' timestamp='1432033809' post='214918']

Did you add the following code at the beginning of the file?



use Tygh\Mailer;


[/quote]

Yes i added it, But still not working.

Do you see the “Referal Link Sent” notification?

[quote name='eComLabs' timestamp='1432039984' post='214944']

Do you see the “Referal Link Sent” notification?

[/quote]



No it was not showing any notification. It was just showing an empty screen.

Please provide me with the temporary FTP access so that we can check it

Did you look in your PHP error_log for an indication of a syntax error in your template? I.e. a Smarty error?

[quote name='tbirnseth' timestamp='1432062507' post='214997']

Did you look in your PHP error_log for an indication of a syntax error in your template? I.e. a Smarty error?

[/quote]



I checked the error_log and it does't have any smarty error.

Then I would suggest you create a local_conf.php file in the root of your store and add the following code:


$my_dbg_ips = array(YOUR_IP_ADDRESS);
if( !empty($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], $my_dbg_ips) && !defined('DEVELOPMENT') ) {
define('DEVELOPMENT', true);
ini_set('display_errors', true);
error_reporting(E_ALL);
}


This will enable development mode and enable all PHP notices/errors/warnings to be sent to error_log and to the screen, but for your IP only. You can add other IP's to the array.