Naeem92's avatar

i am facing issue regarding when i attach dynamically image in email laravel api

please guide me Symfony\Component\Mime\Exception\InvalidArgumentException: Path "https://bizbuysell.jgago.com/bizapp/public/media/slider/julian.jpg" is not readable. in file /home/jgago/subdomains/bizbuysell/bizapp/vendor/symfony/mime/Part/DataPart.php on line 65

0 likes
50 replies
Sinnbeck's avatar

It seems you are trying to attach a file from an url instead of a local path? Show the code for it

Naeem92's avatar

@Sinnbeck $fileToPath=[]; foreach ($businesses as $fileToPath) { foreach ($fileToPath->slider_images as $slider_image) { $fileToPath=$slider_image->full_path.$slider_image->file_name; } }

Naeem92's avatar

@Sinnbeck class BusinessEmailMonthly extends Mailable { use Queueable, SerializesModels; public $businesses; public $fileToPath;

/**
 * Create a new message instance.
 *
 * @return void
 */
public function __construct($businesses,$fileToPath)
{
    $this->businesses=$businesses;
    $this->fileToPath=$fileToPath;
   
    
  
}

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
   
      
    return $this->subject('New Business Alert')->view('emails.business_email_monthly')->attach($this->fileToPath);
}

}

Naeem92's avatar

@Sinnbeck sir please have you any skype account or whatsapp please share me i stuck in this issue for one week please help me sir

Sinnbeck's avatar

@Naeem92 sorry but I don't work freelance. I help out on this forum for free, but that's it :) but we help many people here each and every day

Sinnbeck's avatar

@Naeem92 are you sending multiple emails in a foreach loop? I don't understand how that foreach is related

Sinnbeck's avatar

@Naeem92 so $fileToPath is then an array of images, not a single image?

Can you show the output of dd($fileToPath);

Sinnbeck's avatar

@Naeem92 that's an url. Have you stored the full url to files in the database in column slider_images ?

Sinnbeck's avatar

@Naeem92 that would be the issue then. Is that your domain or are you pointing to files on another site?

Sinnbeck's avatar

Ok quickly take down your site. Your env file is exposed. Seems you are trying to run laravel from a subdirectory. Don't do that. Try calling the website /bizapp/.env

Sinnbeck's avatar

Remember to change all of your passwords from that file

Naeem92's avatar

sir this is not possible i can not done this because i am junior developer my senior not allowing me

Sinnbeck's avatar

@Naeem92 you have a senior that has exposed your sites passwords? Did you tell them that everyone has access to passwords to your database and such ?

Sinnbeck's avatar

@Naeem92 or do you mean you are not allowed to store just the filename in the database instead of the full url?

Tray2's avatar

@Naeem92

You need to set the document root to the /public directory.

Then you need to change all the passwords that you have in your .env file.

As it is now anyone can get access to your database and any other service that you have credentials for in your .env.

Sinnbeck's avatar

@Naeem92 Solution for what? How to set up a laravel site on shared hosting? Or how to delete your files on there?

Sinnbeck's avatar

@Naeem92 Can I recommend you fix your site first? Currently anyone has full access to your personal passwords and stripe keys. I would say that is more important that sending emails

Naeem92's avatar

@Sinnbeck sir how we resolve path "bizbuysell.jgago.com/bizapp/public/media/slider"path is not readable.

Sinnbeck's avatar

@Naeem92 What exactly is stored in the database? An url (with http://) or a path? If its an url, then store the path instead. Like /media/slider/imagename.jpg

Sinnbeck's avatar

@Naeem92 that folder path is an url, not a path

Try

public_path('media/slides'. $slider_image->file_name);
Naeem92's avatar

@Sinnbeck yes is we use public_path('media/slider'.$slider_image->file_name) instead of $fileToPath=$slider_image->folder.$slider_image->file_name;

Tray2's avatar

@Naeem92 Solve the security issue first before anything else.

The username and password to your database is viewable by all. Your stripe keys as well and your mail password.

Not a single page works on your public server either.

I suggest deleting everything on it and start over properly.

You need to set the proper document root and you need to have mod_rewrite enabled (If you are running apache). The proper document root is your apps public directory.

Naeem92's avatar

@Sinnbeck but sir when i use public_path it will give wrong url "/home/jgago/subdomains/bizbuysell/bizapp/public/media/slider/julian.jpg" this is not open in browser

Sinnbeck's avatar

@Naeem92 url? You are trying to give it a path to attach the file, not add an image to the mail body

Tray2's avatar

@Naeem92

Step 1. Remove all the files from the server.

Step 2. Setup the proper document root

Step 2.5. If you are using apache make sure mod_rewrite is enabled.

Step 3. Install the application.

Step4. Update the .env to fit you settings.

Naeem92's avatar

@Sinnbeck sir i am facing issue regarding crone job i set cron job in cpanel but i am not receive emai please guide me where is error

Sinnbeck's avatar

@Naeem92 That sounds like a new issue. And your passwords are still exposed. I am impressed no one has abused your email yet (or maybe they have but you dont know about it)

Sinnbeck's avatar

@Naeem92 No. This sounds completely unrelated. If the issue regarding attaching images was solved, then mark this thread as solved and create a new thread with the new issue

Please or to participate in this conversation.