Hello, I have been switching a script from using mail() to using PHPMailer so that I could use authentication with SMTP.
I seem to have a handle on it when I send one email but if I try to send multiple emails I get all kind of errors (an authentication error, a 550 relay error and a sender already given error):
Webmasters have NOT been notified of your new review due to an error
SMTP Error: Could not authenticate.
The Artist has been notified of your new review. Thank you so much for your contribution to the site!
The Label has NOT been notified of your new review at due to an error
SMTP Error: The following recipients failed: wasserwirbel@gmail.com
SMTP server error: acidic.aquariusstorage.com (www.chaindlk.com) [69.16.232.8] is currently 550-not permitted to relay through this server. Perhaps you have not logged 550-into the pop/imap server in the last 30 minutes or do not have SMTP 550 Authentication turned on in your email client.
xxxxxxxx@gmail.com has NOT been notified of your new review due to an error
The following From address failed: from@chaindlk.com
SMTP server error: sender already given
I did some research and found a post on a website called phpfreaks.com that suggested using sleep() between every email but that didn't work either. I am wondering whether it is a problem on my end (the code I wrote) and was hoping somebody could take a look and offer some advice.
Thanks in advance for taking the time.
// Send E-Mail to Webmasters!
$mail->Subject = 'NEW REVIEW: '.$_POST["artist"].( isset($_POST["title_work"]) ? ' - "'.$_POST["title_work"].'"' : '' );
$body = 'NEW REVIEW:<br /><br />
Artist: '.$_POST["artist"].'<br />
Title: '.( isset($_POST["title_work"]) ? $_POST["title_work"] : '' ).'<br />
Label: '.$_POST["label"].'<br />
Distributor: '.$_POST["distributor"].'<br />
Review written by: '.$_SESSION["signature"].' (please forward all relevant emails to this person)<br />
<br />
Review:
TESTING<br />
<br />
Go to the following link to view the review: '.$mail_link.'<br />
<br />
Date: '.$date.'';
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo($_SESSION["email"],'');
$mail->AddReplyTo($email_notification_username1.'@'.$email_notification_domain1,'');
$mail->AddAddress($email_notification_username1.'@'.$email_notification_domain1,'');
$mail->MsgHTML($body);
if(!$mail->Send()) {
$notification_results = '<li>webmasters have <b>NOT</b> been notified of your new review due to an error<br /><br />'.$mail->ErrorInfo.'</li><br />';
} else {
$notification_results = '<li>webmasters have been notified of your new review. Thank you so much for your contribution to the site!</li><br />';
sleep(3);
}
if ( !empty($_POST["email_artist"]) ) {
// email band
$mail->Subject = 'a REVIEW of a product you were involved with ('.$_POST["artist"].( isset($_POST["title_work"]) ? ' - '.$_POST["title_work"] : '' ).') has been posted at the Chain D.L.K. website';
$body = 'A new REVIEW of '.$_POST["artist"].'\'s '.( isset($_POST["title_work"]) ? $_POST["title_work"] : '' ).' has been posted at the Chain D.L.K. website by '.$_SESSION["signature"].' on '.$date.' and you may read it at '.$mail_link.'.<br />';
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo($_SESSION["email"],'');
$mail->AddReplyTo($email_notification_username1.'@'.$email_notification_domain1,'');
$mail->AddAddress($_POST["email_artist"],'');
$mail->MsgHTML($body);
if(!$mail->Send()) {
$notification_results .= '<li><span class="red">The Artist has <b>NOT</b> been notified of your new review at <b>'.$_POST["email_artist"].'</b> due to an error<br /><br />'.$mail->ErrorInfo.' You might want to manually notify '.$_POST["email_artist"].' personally.</span></li><br />';
} else {
$notification_results .= '<li><span class="green">The Artist has been notified of your new review at <b>'.$_POST["email_artist"].'</b>. Thank you so much for your contribution to the site!</span></li><br />';
sleep(3);
}
} else {
if ( $type == "music" )
$notification_results .= '<li><span class="orange">You have not entered an Artist Email contact therefore we were unable to notify the artist of this review. Please contact the artist (or their publicist) manually to let them know about this review and the next time please try to enter an Artist Email address so that they can be automatically notified. Thank you for your efforts.</span></li><br />';
}
if ( !empty($_POST["email_label"]) ) {
// email label
$mail->Subject = 'a REVIEW of a product you were involved with ('.$_POST["artist"].( isset($_POST["title_work"]) ? ' - '.$_POST["title_work"] : '' ).') has been posted at the Chain D.L.K. website';
$body = 'A new REVIEW of '.$_POST["artist"].'\'s '.( isset($_POST["title_work"]) ? $_POST["title_work"] : '' ).' has been posted at the Chain D.L.K. website by '.$_SESSION["signature"].' on '.$date.' and you may read it at '.$mail_link.'.<br />';
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo($_SESSION["email"],'');
$mail->AddReplyTo($email_notification_username1.'@'.$email_notification_domain1,'');
$mail->AddAddress($_POST["email_label"],'');
$mail->MsgHTML($body);
if(!$mail->Send()) {
$notification_results .= '<li><span class="red">The Label has <b>NOT</b> been notified of your new review at <b>'.$_POST["email_label"].'</b> due to an error<br /><br />'.$mail->ErrorInfo.' You might want to manually notify '.$_POST["email_artist"].' personally.</span></li><br />';
} else {
$notification_results .= '<li><span class="green">The Label has been notified of your new review at <b>'.$_POST["email_label"].'</b>. Thank you so much for your contribution to the site!</span></li><br />';
sleep(3);
}
} else {
if ( $type == "music" && isset($_POST["label"]) )
$notification_results .= '<li><span class="orange">You have not entered a Label Email contact therefore we were unable to notify the artist of this review. Please contact the label (or their publicist) manually to let them know about this review and the next time please try to enter a Label Email address so that they can be automatically notified. Thank you for your efforts.</span></li><br />';
}