Mail sending functionalities in Suite CRM - sugarcrm

Can you please list down the mail sending functionalities provided by Suite CRM.
Eg: When the user is assigned to an Account, the user getting a mail notification. But when the user is removed from the account (In the Account 'Edit' page, Change the user by clicking the 'X' button next to the 'Assigned to', then the user is not getting mail that he has been removed.)
Please help me on this.

Hello i did not work on suitecrm i worked on sugarcrm so i am answering your question according to suitcrm.
1. You have to create a email template for it first.An example of Account module send email on status change .
You can add after save logic_hook to account module.
1) Add following line in your custom/modules/Accounts/logic_hooks.php
$hook_array['before_save'][] = Array(1, 'send ', 'custom/modules/Accounts/send_email.php', 'accountSendEmail', 'send_email');
2) Create a php file named "send_email.php" in "custom/modules/Accounts/" folder.
3) Create email template form email module and get 36 char ID of it.
4) Write following code in custom/modules/Accounts/send_email.php file.
class accountSendEmail{
function send_email(&$bean, $event, $arguments)
{
if (empty($bean->fetched_row)) {
require_once("include/phpmailer/class.phpmailer.php");
require_once("modules/Administration/Administration.php");
require_once("modules/EmailTemplates/EmailTemplate.php");
$emailtemplate = new EmailTemplate();
$emailtemplate = $emailtemplate->retrieve("email_template_id");
$emailtemplate->parsed_entities = null;
$temp = array();
$template_data = $emailtemplate->parse_email_template(
array(
"subject" => $emailtemplate->subject,
"body_html" => $emailtemplate->body_html,
"body" => $emailtemplate->body
),
'Accounts',
$bean,
$temp
);
$email_body = $template_data["body_html"];
$email_subject = $template_data["subject"];
$admin = new Administration();
$admin->retrieveSettings();
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $admin->settings['mail_smtpserver'];
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = $admin->settings['mail_smtpuser'];
$mail->Password = $admin->settings['mail_smtppass'];
$mail->From = $admin->settings['notify_fromaddress'];
$mail->FromName = $admin->settings['notify_fromname'];
$mail->Subject = $email_subject;
$mail->Body = from_html($email_body);
$mail->IsHTML(true);
$mail->AddAddress('your#email.address');
if (!$mail->send()) {
$GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
$is_send = 'notsend';
} else {
$is_send = 'send';
}
}
}
}
Please check this link it help you :
Link 1
Link 2
Link 3
Above steps are to send emails through code , i sugar there is new concept which is PRocess you can send email on process also.
Process
I think this will help you it help me a lot regarding the emails.

// require_once('phpmalier.php');
$mail = new SugarPHPMailer();
//
// $mail->setMailerForSystem();
// $mail->From = $focus->settings['notify_fromaddress'];
// $mail->FromName = $focus->settings['notify_fromname'];
// $mail->Subject = $subject;
// $mail->IsHTML(true);
// $mail->Body = $body;//$html_body;
// $mime_type = "application/pdf";
// $mail->AddAttachment($sugar_config['upload_dir'] . $file_name.'.pdf', $file_name, 'base64', $m`enter code here`ime_type);
// $mail->prepForOutbound();
// $mail->AddAddress($To_email);
//if (!$mail->Send()) {
//$GLOBALS['log']->fatal("Email for Cases# " . $bean->name . " is not sent. Please check Email id of the contact ");
// }

Related

Send mail using an email account created on Hostinger (PHP)

I am sending an email through PHPMailer, the code is hosted on hostinger's hpanel and I am using an email I created on the hpanel. After running the code, I get no errors, and no feedback on whether the mail has been sent, it just doesn't show anything.
Please help me I currently don't know what to do.
require '../../vendor/autoload.php';
$mail = new PHPMailer(true);
try
{
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = 'smtp.titan.email';
$mail->SMTPAuth = true;
$mail->Username = 'admin#hostinger.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'SSL';
$mail->Port = 465;
$mail->setFrom('admin#hostinger.com', 'Hostinger');
$mail->addAddress($email, $username);
$mail->addReplyTo('admin#hostinger.com', 'For any Information');
$mail->addCC('admin#hostinger.com');
$mail->isHTML(true);
$mail->Subject = 'Sending message';
$mail->Body = $message;
$mail->AltBody = "Hello there";
$mail->send();
echo "Sent";
}
catch (Exception $eax)
{
echo 'EMAIL SENDING FAILED. INFO: '.$mail->ErrorInfo;
}
No need to Use
$mail->isSMTP();
Comment $mail->isSMTP();
Make sure you are using the right smtp host:
$mail->Host = 'smtp.hostinger.com'

Contact Form Using SMTP

I have a simple contact form that works if I do not use smtp. I've tried to add smtp to use with mandrill, but it doesn't work. Emails aren't going through to mandrill.
I do not see any errors after sending either even if I enabled '$mail->SMTPDebug = 1;' I've tried on both local and live server environments.
<?php
require_once('../mail/class.phpmailer.php');
$emailaddress = "name#domain.com";
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$ip = $_SERVER['REMOTE_ADDR'];
$message = $_POST['message'];
$subject = "Contact Form: $name";
$body = "You have received a new message from website.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nIP Address: $ip\n\nMessage:\n$message";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.mandrillapp.com";
//$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = "smtp.mandrillapp.com";
$mail->Port = 587;
$mail->Username = "username";
$mail->Password = "password";
$mail->CharSet = 'UTF-8';
$mail->SetFrom($email_address);
$mail->AddReplyTo($email_address);
$mail->Subject = "Contact Form: ".$_POST['name']." ";
$mail->MsgHTML($body);
$mail->AddAddress($emailaddress);
$mail->Send();
?>
I figured it out. I needed to also include the 'class.stmp.php' file as well. It doesn't have to be call, but needs to in the same folder as 'class.phpmailer.php.'

How do I AddAddress automatically in PHPmailer from form php info?

This has got to be a simple one, but I've been searching all over and nothing seems relevant to my problem: or i'm not able to interpret advice for others adequately.
I'm getting the error "You must provide at least one recipient email address. Message could not be sent."
If I put a specific email address in 'AddAddress' field the message is sent. I want to have an email sent to the user who has submitted their form as an automatic email response thanking user for registering... Thus the ($_POST['email']) in the 'AddAddress' field. This works in Mail() php function. Why not PHP MAiler? What am I missing?
Here is my code with sensitive bits taken out (Relevant bit - I think - in bold):
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name=""; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$email=$_POST['email'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(email,) VALUES('$email',)";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
}
else {
echo "ERROR";
}
?>
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "localhost"; // specify main and backup server
$mail->SMTPAuth = false; // turn on SMTP authentication
$mail->Username = ""; // SMTP username
$mail->Password = ""; // SMTP password
$mail->From = "";
$mail->FromName = "";
**$mail->AddAddress = ($_POST['email']);**
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "";
$mail->Body = "";
$mail->AltBody = "";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
<?php
// close connection
mysql_close();
?>
Many thanks in advance for your advice. Hopefully this will help others too...
Ed
Simple one... just change this line
$mail->AddAddress = ($_POST['email']);
to this:
$mail->AddAddress($_POST['email']);
as it is a method, as opposed to a variable, on the class! :)
there are some good examples you can use on the PHPMailer GitHub

how do i make this form (sleek contact form) send to multiple recipients?

I'm looking to make a contact form send to more than 1 address. currently the code is
$to = 'email#email.com';
Further down the code is
function xmail($to,$subject,$message,$headers){
global $usesmtp,$smtphost,$smtpport,$smtpuser,$smtppass,$smtpsecure,$_POST;
if($usesmtp!=1){
if(#mail($to,$subject,$message,$headers)){
return 1;
}
}else{
require_once('mail/class.phpmailer.php');
$mail = new PHPMailer();
$body =$message;
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = $smtpsecure;
$mail->Host = $smtphost;
$mail->Port = $smtpport;
$mail->Username = $smtpuser;
$mail->Password = $smtppass;
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, "Administrator");
if($mail->Send()) {
return 1;
}
}
}
Can anyone help please?
Changed
$to = 'email#email.com';
To
$to = 'email#email.com, email2#email2.com';

phpmailer noname attachment

I'm using phpmailer to send email. But all of my emails are send with noname attachement. I already checked if variables are set before I use addAttachemnt function and they are. It looks like this:
$fname = $_FILES['file']['name'];
$fTmpName = $_FILES['file']['tmp_name'];
$mail = new PHPMailer();
$mail->From = "mymail#mymail.com";
$mail->FromName = "mymail.com"; //moje meno
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->Host = "smtp.mymail.com";
$mail->Subject = "Subject";
$mail->AddAddress($email);
echo $fnameZivotopis;
$mail->AddAttachment($fTmpName,$fname);
$mail->Body = $msg;
$mail->Send(); // send message
Try to use AddStringAttachment(string $att_file_data, string $att_file_name, ...).