Jump to content

PHPMailer 2.3 via Smart Pill


This topic is 5328 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi All,

I'm using the testbed php email 2.3 example in my code. This works great!. I changed my server settings form sbc to gmail and now its broke.

The settings I'm using are in FM fields and I'm useing them in FM SMTP Server setting in the send mail function. Works great. The only differences I see are the Authenticate "plain password and ssl is checked. I do not have settings in my php code for these and are not sure they are available.

Things I've tried.

Did a google search for php gmail.

1. updating the code to PHPMail to 5.02. Did not work.

2. change my host to mail=>Host = 'ssl://smtp.gmail.com Did not work

3. I also learned there is specfic order to mail function.

/ create the mail object

$mail = new PHPMailer();

// specify that we want an SMTP connection

$mail->IsSMTP();

// set the SMTP host address

$mail->Host = $host;

// set the SMTP port, if any

if ( !empty($port) ) {

$mail->Port = $port;

}

// set the SMTP login credentials, if any

if ( !empty($username) ) {

$mail->SMTPAuth = TRUE;

$mail->Username = $username;

$mail->Password = $password;

$mail->SMTPDebug = $debugLevel;

}

Error Received:

SMTP -> Error: Failed to connect to Server: (0)

Error Info: smtp error: conld not connect to smtp host.

This is still not working.

Any suggestion would be appreciated.

I'm at my wits end.

Todd Dignan

Link to comment
Share on other sites

Here is the solution, tested with gmail and sbc

I add a couple of lines:

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl";

Then I reordered the calls per the use_gmail.txt included in the phpMailer_v2.3 documentation.

// create the mail object

$mail = new PHPMailer();

// specify that we want an SMTP connection

$mail->IsSMTP();

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl";

// set the SMTP host address

$mail->Host = $host;

// set the SMTP port, if any

if ( !empty($port) ) {

$mail->Port = $port;

}

// set the SMTP login username, if any

if ( !empty($username) ) {

$mail->Username = $username;

}

// set the SMTP login password, if any

if ( !empty($password) ) {

$mail->Password = $password;

}

// set the From address

$mail->From = $from;

// set the FromName, so the email doesn't arrive from Root User

$mail->FromName = $fromname;

// set the subject

$mail->Subject = $subject;

// set the body (and altbody, if any)

if ( !empty($htmlMessage) ) {

$mail->IsHTML(TRUE);

$mail->AltBody = $message;

$mail->Body= $htmlMessage;

} else {

$mail->IsHTML(FALSE);

$mail->Body = $message;

$mail->WordWrap = 50; // set word wrap

}

// set the ReplyTo address, if any

if ( !empty($replyTo) ) {

$mail->AddReplyTo($replyTo);

}

// set the CC addresses, if any

if ( !empty($ccs) ) {

$addresses = explode(',', $ccs);

foreach( $addresses as $address ) {

$mail->AddCC(trim($address));

}

}

// set the BCC addresses, if any

if ( !empty($bccs) ) {

$addresses = explode(',', $bccs);

foreach( $addresses as $address ) {

$mail->AddBCC(trim($address));

}

}

// set attachments, if any

if ( !empty($attachments) ) {

$paths = explode(',', $attachments);

foreach( $paths as $path ) {

$mail->AddAttachment(trim($path));

}

}

// set the To addresses

$addresses = explode(',', $tos);

foreach( $addresses as $address ) {

$mail->AddAddress(trim($address));

}

// send the message

if(!$mail->Send()) {

echo "Mailer Error: " . $mail->ErrorInfo;

} else {

echo "Message has been sent";

}

Link to comment
Share on other sites

This topic is 5328 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.