Good morning,
I’ve spent days and days trying to get this to work, and have searched the threads trying this and that and I’m still missing something here. I’m trying to get a form built, that when completed and submitted, sends two emails - one to one group of folk, and another email to another group. Main reason for this is because one group is not allowed to see part of the data being submitted. On both emails however, I need to include the picture that the person filling out the form has attached.
I read that it’s better practice to add to the database, a link to the image verse having the image saved in the database…and I’ve tried both ways for the email attachment to be included but failed on them all. I’m deploying to HostGator if that makes any difference and the emails go out fine to the groups they need to go to, but the image is never there… I’ve even included a hard link in the email to an image I know is there (I can open up the link in my browser and see the image) but the attachment is still not successful.
Here is my code edited a bit for privacy so hopefully I didn’t mess that up - all on event “OnAfterInsert”:
===============================
[rptid] = {Rcrdid};
$mail_message = NULL;
// Get details of new submission
$check_sql = “SELECT added, name, image FROM reports WHERE rcrdid = [rptid]”;
sc_lookup(rp, $check_sql);
[rp_added] = {rp[0][0]};
[rp_name] = {rp[0][1]};
[image] = {rp[0][3]};
// Get email settings for sending mail
sc_lookup(em, “SELECT smtp_server, smtp_user, mail_from, smtp_pwd, mail_to_attorney, mail_to_board FROM mail_settings WHERE type = ‘main’”);
[server] = {em[0][0]};
[user] = {em[0][1]};
[from] = {em[0][2]};
[pwd] = {em[0][3]};
[sendto] = {em[0][4]};
// Set image path - directory
[fp] = “…/_lib/file/img/”;
// ** Send email notification
// Email parameters
$mail_smtp_server = “[server]”; // SMTP server name or IP address
$mail_smtp_user = “[user]”; // SMTP user name
$mail_smtp_pass = “[pwd]”; // SMTP password
$mail_from = “[from]”; // From email
$mail_to = “[sendto]”; // To email
$mail_subject = "New Submission: " . [rptid]; // Message subject
$mail_message = $mail_message.‘The following information was just submitted from the site: <br><br>’; // Message body
$mail_message = $mail_message.'Reported date: ’ . date(“l, jS \of F Y”,strtotime([rp_added])) . ‘<br>’;
$mail_message = $mail_message."Individual reporting: " . [rp_name] . “<br>” ;
$mail_message = $mail_message.'Thank you. ’ . ‘<br>’;
$mail_format = ‘H’; // Message format: (T)ext or (H)tml
$mail_attachments = ‘[fp].[image]’;
// Send email";
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format,
‘’,
‘’,
‘’,
$mail_attachments);
Then I clear it the message out with
$mail_message = NULL;
Before doing a similar action for the second email.
I’ve tried so many different variations that I’ve lost track of them all, but I must be missing something somewhere and hopefully it’s an easy catch for someone else?
Thanks very much for any help you’re able to provide.
Mark.