[FX.php List] [off] Trying to send mail thru Gmail

Bob Patin bob at patin.com
Wed Jan 2 13:02:59 MST 2013


Hey Marc,

I've never used FMStudio, but have started using PHPMailer, which is really easy to configure and makes it super-simple to send PDF attachments.

If you're trying to send through GMail, here are the settings I use (this is the entire script:

<?php

include_once('includes/class.phpmailer.php');

function smtpmailer($to, $from, $from_name, $subject, $body) {
    global $error;
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = '<YOUR GMAIL ACCOUNT>@gmail.com';
    $mail->Password = '<PUT PASSWORD HERE>';
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
	$mail->AddAttachment('Tickets.pdf'); // if you have an attachment to send
    $mail->AddAddress($to);
    if(!$mail->Send()) {
        $error = 'Mail error: '.$mail->ErrorInfo;
        return false;
    } else {
        $error = 'Message sent!';
        return true;
    }
}

$subject = 'Ticket Purchase Confirmation';


smtpmailer($email, 'info at longtermsolutions.com', 'Longterm Solutions', $subject, $body );

?>

In your INCLUDES folder (or wherever), you'll need these two files, which you'll get in the PHPMailer download:

class.phpmailer.php
class.smtp.php

Good luck!

Bob Patin
Longterm Solutions LLC
bob at longtermsolutions.com
615-333-6858
http://www.longtermsolutions.com
FileMaker 9, 10 & 11 Certified Developer
Member of FileMaker Business Alliance and FileMaker TechNet
--
Twitter: bobpatin
Google+: http://www.longtermsolutions.com/plus
AIM: longterm1954
iChat: bobpatin
--
Expert FileMaker Consulting 
FileMaker Hosting for all versions of FileMaker

On Jan 2, 2013, at 1:05 PM, NSPA/ACP <webmaster at studentpress.org> wrote:

> Bob,
> 
> Did you ever figure this out? I'm still using the old FMStudio Email Module for sending emails, and I can't see where/how to specify SSL in the FMStudio part of the module or the PEAR Mail part. 
> 
> I think SSL is enabled in my PHP install and port 465 isn't blocked on the server. 
> 
> If I use port 587, which was the port I used with our previous email provider, with smtp.gmail.com, I get a quick, standard-looking error response, but if I use 465 I see a lengthy timeout process, followed by a more cryptic error message.
> 
> The link that Steve Winter provided references PHPMailer, so maybe I need to switch to that. I don't use FMStudio at all anymore, but some of their code is still hanging around in places where I haven't had any need to update it.
> 
> Thanks,
> Marc Wood

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20130102/e9352f11/attachment.html


More information about the FX.php_List mailing list