Small update, seems I’m getting the e-mails but only some of them and about 2 to 3 days after I sent them. I started to note the changes I made to files in each of the emails to hopefully get a clue what’s working and what’s not. Now I’m starting to get those emails so I’m not sure if my configuring changes are making a difference, since they are coming in, it’s just taking forever.
I could try running a script using phpmailer and gmail just on the server and out of Modx to see if I get the email sooner or not. Worth a shot.
---EDIT 12/18/10---
Ok so far I have been able to receive emails extremely fast on my Wamp server and the live host I’m using when I’m just accessing the "test_smtp_gmail_basic.php" file that came along with phpmailer. So that would exclude server side errors right? Or at least my live server isn’t fouling outgoing mail.
Now I don’t know if this counts as a proper test, but I made a plain old text link to that file (test_smtp_gmail_basic.php), on a page built in Modx and it sent nice and quick just like the rest. So that would lead me to believe it’s something with eform.
Does anyone know of a tutorial that explains how to configure the eform.inc.php for smtp? When I look at it there are like five different places to put that information but I don’t know which ones to change. I tried changing all of them and got an error when trying to send info via my form.
In the meantime, my next plan of action is to build a form on my own and then code a php script that not only pulls relevant information from the form but also sends it smtp through gmail. I know this might sound obvious and easy to some but I’m a complete noob when it comes to this stuff.
If anyone has a link to a tutorial for that too, that would be awesome.
---EDIT 12/18/10 7:39 pm---
Ok took another crack at the eform.inc.php file when I read (in this forum post:
http://modxcms.com/forums/index.php/topic,29138.0.html) that you can’t expect to receive mail if you only change the first mail code (the send abuse alert section). So going by that I looked over the php file and found this section of code:
# send form
//defaults to html so only test sendasText
$isHtml = ($sendAsText==1 || strstr($sendAsText,'report'))?false:true;
if(!$noemail) {
if($sendirect) $to = $fields['email'];
$mail = new PHPMailer();
$mail->IsMail();
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $report;
AddAddressToMailer($mail,"replyto",$replyto);
AddAddressToMailer($mail,"to",$to);
AddAddressToMailer($mail,"cc",$cc);
AddAddressToMailer($mail,"bcc",$bcc);
AttachFilesToMailer($mail,$attachments);
if(!$mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
I have no idea if this is the right place, but a "send form" section sounds like a good place to try. So I plug in my configurations and had to add some extra strings of code to target the gmail server and verify everything (if that’s correct).
I ended up with this:
# send form
//defaults to html so only test sendasText
$isHtml = ($sendAsText==1 || strstr($sendAsText,'report'))?false:true;
if(!$noemail) {
if($sendirect) $to = $fields['email'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = '465';
$mail->Username = "[email protected]";
$mail->Password = "password";
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $report;
AddAddressToMailer($mail,"replyto",$replyto);
AddAddressToMailer($mail,"to",$to);
AddAddressToMailer($mail,"cc",$cc);
AddAddressToMailer($mail,"bcc",$bcc);
AttachFilesToMailer($mail,$attachments);
if(!$mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
}
When I tried to fill out my form and send it I now received this error message:
"Main mail: Mailer was unable to send mailThe following From address failed:
[email protected]"
I have no idea if I’m even on the right track, nor what this error means.
---EDIT 12/21/10---
Another update, I tried again to add my gmail server codes to each section of the eform.inc.php file, which I think was about 4 to 5 entries.
It seems now the only error I’m getting with this now is the one I had before:
"Main mail: Mailer was unable to send mailThe following From address failed:
[email protected]"
I’ll post that section of code if it’s helpful. I’m still unsure where the problem is though :’(
//send email to webmaster??
if ($reportAbuse){ //set in snippet configuration tab
$body = $_lang['ef_mail_abuse_message'];
$body .="<table>";
foreach($fields as $key => $value)
$body .= "<tr><td>$key</td><td><pre>$value</pre></td></tr>";
$body .="</table>";
include_once "manager/includes/controls/class.phpmailer.php";
# send abuse alert
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure= "ssl";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxx";
$mail->From = $modx->config['emailsender'];
$mail->FromName = $modx->config['site_name'];
$mail->Subject = $_lang['ef_mail_abuse_subject'];
$mail->Body = $body;
AddAddressToMailer($mail,"to",$modx->config['emailsender']);
$mail->send(); //ignore mail errors in this case
}
//return empty form with error message
//register css and/or javascript
if( isset($startupSource) ) efRegisterStartupBlock($startupSource);
return formMerge($tpl,array('validationmessage'=> $_lang['ef_mail_abuse_error']));
}
# added in 1.4.2 - Limit the time between form submissions
if($submitLimit>0){
if( time()<$submitLimit+$_SESSION[$formid.'_limit'] ){
return formMerge($_lang['ef_submit_time_limit'],$fields);
}
else unset($_SESSION[$formid.'_limit'], $_SESSION[$formid.'_hash']); //time expired
}
# invoke OnBeforeMailSent event set by another script
if ($eFormOnBeforeMailSent) {
if( $isDebug && !function_exists($eFormOnBeforeMailSent))
$fields['debug'] .= "eFormOnBeforeMailSent event: Could not find the function " . $eFormOnBeforeMailSent;
elseif ($eFormOnBeforeMailSent($fields)===false) {
if( isset($fields['validationmessage']) && !empty($fields['validationmessage']) ){
//register css and/or javascript
if( isset($startupSource) ) efRegisterStartupBlock($startupSource);
return formMerge($tpl,$fields);
}
else
return;
}
}
if( $protectSubmit ){
$hash = '';
# create a hash of key data
if(!is_numeric($protectSubmit)){ //supplied field names
$protectSubmit = (strpos($protectSubmit,','))? explode(',',$protectSubmit):array($protectSubmit);
foreach($protectSubmit as $fld) $hash .= isset($fields[$fld]) ? $fields[$fld] : '';
}else //all required fields
foreach($formats as $fld) $hash .= ($fld[3]==1) ? $fields[$fld[0]] : '';
if($hash) $hash = md5($hash);
if( $isDebug ) $debugText .= "<strong>SESSION HASH</strong>:".$_SESSION[$formid.'_hash']."<br />"."<b>FORM HASH</b>:".$hash."<br />";
# check if already succesfully submitted with same data
if( isset($_SESSION[$formid.'_hash']) && $_SESSION[$formid.'_hash'] == $hash && $hash!='' )
return formMerge($_lang['ef_multiple_submit'],$fields);
}
$fields['disclaimer'] = ($disclaimer)? formMerge($disclaimer,$fields):"";
$subject = isset($fields['subject'])?$fields['subject']:(($subject)? formMerge($subject,$fields):$category);
$fields['subject'] = $subject; //make subject available in report & thank you page
$report = ($report)? formMerge($report,$fields):"";
$keywords = ($keywords)? formMerge($keywords,$fields):"";
$from = ($from)? formMerge($from,$fields):"";
$fromname = ($from)? formMerge($fromname,$fields):"";
$to = formMerge($to,$fields);
if(empty($to) || !strpos($to,'@')) $nomail=1;
if(!$nomail){
# check for mail selector field - select an email from to list
if ($mselector && $fields[$mselector]) {
$i = (int)$fields[$mselector];
$ar = explode(",",$to);
if ($i>0) $i--;
if ($ar[$i]) $to = $ar[$i];
else $to = $ar[0];
}
//set reply-to address
//$replyto snippet parameter must contain email or fieldname
if(!strstr($replyto,'@'))
$replyto = ( $fields[$replyto] && strstr($fields[$replyto],'@') )?$fields[$replyto]:$from;
# include PHP Mailer
include_once "manager/includes/controls/class.phpmailer.php";
# send form
//defaults to html so only test sendasText
$isHtml = ($sendAsText==1 || strstr($sendAsText,'report'))?false:true;
if(!$noemail) {
if($sendirect) $to = $fields['email'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure= "ssl";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxx";
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $report;
AddAddressToMailer($mail,"replyto",$replyto);
AddAddressToMailer($mail,"to",$to);
AddAddressToMailer($mail,"cc",$cc);
AddAddressToMailer($mail,"bcc",$bcc);
AttachFilesToMailer($mail,$attachments);
if(!$mail->send()) return 'Main mail: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
}
# send user a copy of the report
if($ccsender && $fields['email']) {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure= "ssl";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxx";
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $report;
AddAddressToMailer($mail,"to",$fields['email']);
AttachFilesToMailer($mail,$attachments);
if(!$mail->send()) return 'CCSender: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
}
# send auto-respond email
//defaults to html so only test sendasText
$isHtml = ($sendAsText==1 || strstr($sendAsText,'autotext'))?false:true;
if ($autotext && $fields['email']!='') {
$autotext = formMerge($autotext,$fields);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure= "ssl";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxx";
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = ($autosender)? $autosender:$from;
$mail->FromName = ($autoSenderName)?$autoSenderName:$fromname;
$mail->Subject = $subject;
$mail->Body = $autotext;
AddAddressToMailer($mail,"to",$fields['email']);
if(!$mail->send()) return 'AutoText: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
}
//defaults to text - test for sendAsHtml
$isHTML = ($sendAsHTML==1 || strstr($sendAsHtml,'mobile'))?true:false;
# send mobile email
if ($mobile && $mobiletext) {
$mobiletext = formMerge($mobiletext,$fields);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure= "ssl";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxx";
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML($isHtml);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $mobiletext;
AddAddressToMailer($mail,"to",$mobile);
$mail->send();
}
}//end test nomail
# added in 1.4.2 - Protection against multiple submit with same form data
if($protectSubmit) $_SESSION[$formid.'_hash'] = $hash; //hash is set earlier
# added in 1.4.2 - Limit the time between form submissions
if($submitLimit>0) $_SESSION[$formid.'_limit'] = time();
# invoke OnMailSent event set by another script
if ($eFormOnMailSent) {
if( $isDebug && !function_exists($eFormOnMailSent) )
$fields['debug'] .= "eFormOnMailSent event: Could not find the function" . $eFormOnMailSent;
else
if ($eFormOnMailSent($fields)===false) return;
}