Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6172707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:26:23+00:00 2026-05-23T23:26:23+00:00

Right now, i am reading in an array and doing a foreach loop on

  • 0

Right now, i am reading in an array and doing a foreach loop on the array to run a set script, in this case, PHPmail. In that array, I have it working 100% to send the array to update the subject file. I want to update the code so that the script will still run on one foreach loop but will read in two separate strings (almost in effect in parallel) that will be delimited by a character… for example the character ~ …

so, assume “list” had the following
SUBJECT Goes here~/home/username/filename
SUBJECT went here~/home/username2/filename2

Right now, the code would read in each line above as SubjectLiner and send the enter line in the subject.

I want the PHP to break these apart so that when the php is ran it would pull these two apart in one sequence. Right now, it works great without the ~ or the attachement component. (or the one many works just fine… i want to get the one to one working)..

so the desired result would be on the first pass
SubjectLiner would be “SUBJECT Goes here”
AttachmentLiner would be “/home/username/filename”
and then on the second pass:
SubjectLiner would be “SUBJECT went here”
AttachmentLiner would be “/home/username2/filename2

below the is code I am testing.. I dont know how delimit based on a qualifier ~ in my example above.. and then have the two strings processed.

This same thing can be accomplished with two separate files that are matched line for line.. but the risk goes exponentially up to send the wrong attachment.

At the end of the day, I need to send a routine email to the same recipient (a server) that has a different Subject (w/ spaces and ;s) and different attachements. I have it 85% beaten. It is the dual information per line that is needed. Super appreciate any comments. thx.

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

$addylist = file("list"); // Subject line feeder.

foreach($addylist as $SubjectLiner)
{
$mail = new PHPMailer();
$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username = "username";  // SMTP username
$mail->Password = "yourpassword"; // SMTP password
$mail->From = "username";
$mail->FromName = "username";
$mail->AddReplyTo("FromAddy", "From Name");
$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML
$mail->AddAddress("ToAddy", "To Name");
$mail->Body    = "";
$mail->AltBody = "";

$mail->Subject = $SubjectLiner;

$mail->AddAttachment("$AttachmentLiner");         // add attachments



if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}


}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:26:24+00:00Added an answer on May 23, 2026 at 11:26 pm

    Explode the $SubjectLiner and use the two parts:

    <?php
    require("class.phpmailer.php");
    
    $addylist = file("list"); // Subject line feeder.
    
    foreach($addylist as $SubjectLiner)
    {
        $SubjectLiner = explode("~",$SubjectLiner);
        $subject = $SubjectLiner[0];
        $attachment = $SubjectLiner[1];
    
        //$mail = .... Same as in your example
    
        $mail->Subject = $subject;
        $mail->AddAttachment($attachment);         // add attachments
    
        if(!$mail->Send())
        {
           echo "Message could not be sent. <p>";
           echo "Mailer Error: " . $mail->ErrorInfo;
           exit;
        }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I
Right now I have an SSIS package that runs every morning and gives me
I have a byte array that I am reading in from a NetworkStream. The
I am reading through a Learn C book right now and have come across
Right now I have two tables for getting a timeline of posts that a
another request sorry.. Right now I am reading the tokens in one by one
Right now, I'm particularly interested in reading the data from MP3 files (ID3 tags?),
Right now, I keep all of my projects on my laptop. I'm thinking that
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.