Jump to content

Recommended Posts

I am trying to send out a personalized email that gets the recipient's (owner's) name and their password from my database.  I can only get the yachtname to pull in, but not the other information I want.  I know this should be easy, and the connection seems to be valid, as the yachtname is there, so I'm stumped!

 

Thanks for any help.

 

The code follows:

 

 

<?php require("class.phpmailer.php");

 

$mail = new PHPMailer();

 

$mail->From    = "sales@crossbonescharters.com";

$mail->FromName = "Alan & Alanna Godsey";

$mail->Subject  = "Contract for $yachtname";

@MYSQL_CONNECT("mysqlxxxx.secureserver.net");

@mysql_select_db("database");

$query  = "SELECT owner,email,password FROM Yachts WHERE yachtname=%s";

$result =  @MYSQL_QUERY($query);

{

 

// HTML body

 

</p>';

$body .= "Dear $owner, <br /><br />" ;

$body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser<br />";

$body .= "and log in using your password: $password.  If you have questions, please contact us. <br /><br/>";

$body .= "Sincerely, <br /><br />";

$body .= "CROSSBONES CHARTERS <br />";

$body .= "Alan & Alanna Godsey <br />";

$body .= "Toll Free 1-877-922-4802";

 

    // Plain text body (for mail clients that cannot read HTML)

    $text_body .= "Dear $owner, \n\n";

    $text_body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser\n";

$text_body .= "Your password is $password \n";

$text_body .= "Sincerely, \n";

    $text_body .= "Alan L. Godsey";

 

$mail->Body    = $body;

    $mail->AltBody = $text_body;

    $mail->AddAddress($row_Recordset2['email'], $row_recordset2['owner']);

 

    if(!$mail->Send())

        echo "There has been a mail error sending to " . $row_recordset2['email'] . "<br>";

if($row->MailType == 'html')

  {

    $mailer->Body = str_replace('{owner}', $owner, $htmlBody);

$mailer->Body = str_replace('{password}', $passwordr, $htmlBody);

    $mailer->IsHTML(true);

    $mailer->AltBody = str_replace('{owner}', $owner, $textBody);

$mailer->AltBody = str_replace('{password}', password, $textBody);

  }

  else

  {

    $mailer->Body = str_replace('{owner}', $owner, $textBody);

$mailer->Body = str_replace('{password}', $password, $textBody); 

  }

Link to comment
https://forums.phpfreaks.com/topic/52130-phpmailer/
Share on other sites

I took care of the Warning message.  I'm still not getting the resulting email I'm looking for.  Following is my exact code, and following that is the exact resulting email.

 

Thanks for your help!

Alan

 

<?php require("class.phpmailer.php");

 

$mail = new PHPMailer();

 

$mail->From    = "sales@crossbonescharters.com";

$mail->FromName = "Alan & Alanna Godsey";

$mail->Subject  = "Contract for $yachtname";

@MYSQL_CONNECT("mysql37.secureserver.net");

@mysql_select_db("crossboneschart.Yachts");

$query  = "SELECT owner,email,cya_number FROM crossboneschart.Yachts WHERE yachtname='1'";

$result =  @MYSQL_QUERY($query); // execute query

$row_recordset2 = mysql_fetch_array($result); // abstract data from query resource

{

 

// HTML body

$body .= "Dear $owner, <br /><br />" ;

$body .= "We have recieved a partially executed contract for $yachtname.<br /><br />";

$body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser

and log in using your password: $cya_number.  For this contract to become a definite booking, you will  need to fill in your information and submit it.<br /><br />";

$body .= "If you have questions, please contact us. <br /><br/>";

$body .= "Sincerely, <br /><br />";

$body .= "CROSSBONES CHARTERS <br />";

$body .= "Alan & Alanna Godsey <br />";

$body .= "sales@crossbonescharters.com<br />";

$body .= "Toll Free 1-866-922-4802";

 

    // Plain text body (for mail clients that cannot read HTML)

    $text_body .= "Dear  '{owner}', \n\n";

    $text_body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser\n";

$text_body .= "Your password is '{cya_number}' \n";

$text_body .= "Sincerely, \n";

    $text_body .= "Alan L. Godsey";

 

$mail->Body    = $body;

    $mail->AltBody = $text_body;

  $mail->AddAddress($row_Recordset2['email'], $row_recordset2['owner']);

 

    if(!$mail->Send())

        echo "There has been a mail error sending to " . $row_recordset2['email'] . "";

 

if($row->MailType == 'html')

  {

    $mailer->Body = str_replace('{owner}', $owner, $body);

$mailer->Body = str_replace('{cya_number}', $cya_number, $body);

    $mailer->IsHTML(true);

    $mailer->AltBody = str_replace('{owner}', $owner, $textBody);

$mailer->AltBody = str_replace('{cya_number}', cya_number, $textBody);

  }

  else

  {

    $mailer->Body = str_replace('{owner}', $owner, $textBody);

$mailer->Body = str_replace('{cya_number}', $cya_number, $textBody); 

  }

    // Clear all addresses and attachments for next loop

    $mail->ClearAddresses();

    $mail->ClearAttachments();

}?> 

 

Subject: Contract for Test Yacht

From:Alan & Alanna Godsey <sales@crossbonescharters.com>

To: alan@crossbonescharters.com

Dear ,

 

We have recieved a partially executed contract for Test Yacht.

 

Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser and log in using your password: . For this contract to become a definite booking, you will need to fill in your information and submit it.

 

If you have questions, please contact us.

 

Sincerely,

 

CROSSBONES CHARTERS

Alan & Alanna Godsey

sales@crossbonescharters.com

Toll Free 1-866-922-4802

Link to comment
https://forums.phpfreaks.com/topic/52130-phpmailer/#findComment-258786
Share on other sites

Man why not you use Zigmoyd mailer ??

Its too cool and too easy.

When I used it, My server didn't have SMTP. So the mail was routed from another server. and I used the group mail class its as easy as 2+2=4.

and to determine the group I've used browse class.

And then I was a noob I made so many mistakes But Zigmoyd parsed it with Artificial Inteligence. And mail goes directly to INBOX.And its ofcourse faster than PHPmailer.

Link to comment
https://forums.phpfreaks.com/topic/52130-phpmailer/#findComment-258787
Share on other sites

This should do the trick.

 

<?php require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->From     = "sales@crossbonescharters.com";
$mail->FromName = "Alan & Alanna Godsey";
$mail->Subject  = "Contract for $yachtname";
mysql_connect("mysql37.secureserver.net");
mysql_select_db("crossboneschart.Yachts");
$query  = "SELECT owner,email,cya_number FROM crossboneschart.Yachts WHERE yachtname='1'";
$result =  MYSQL_QUERY($query); // execute query
list($owner, $email, $cya_number) = mysql_fetch_row($result); // abstract data from query resource

// HTML body
$body .= "Dear $owner,

" ;
$body .= "We have recieved a partially executed contract for $yachtname.

";
$body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser
and log in using your password: $cya_number.  For this contract to become a definite booking, you will  need to fill in your information and submit it.

";
$body .= "If you have questions, please contact us.

";
$body .= "Sincerely,

";
$body .= "CROSSBONES CHARTERS
";
$body .= "Alan & Alanna Godsey
";
$body .= "sales@crossbonescharters.com
";
$body .= "Toll Free 1-866-922-4802";

// Plain text body (for mail clients that cannot read HTML)
$text_body .= "Dear  {$owner}, \n\n";
$text_body .= "Paste 'http://www.crossbonescharters.com/contract_sign_in.php' into your browser\n";
$text_body .= "Your password is {$cya_number} \n";
$text_body .= "Sincerely, \n";
$text_body .= "Alan L. Godsey";

$mail->Body    = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($email, $owner);

if(!$mail->Send())
echo "There has been a mail error sending to " . $row_recordset2['email'] . "";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/52130-phpmailer/#findComment-259094
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.