Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

akash-chawan's avatar

How to add Proxy in Mail laravel

Needs to send email using proxy in laravel 8. Cannot able to send email by just using mail. on client server need to add proxy then only mails are getting sent. Example $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true); curl_setopt($ch, CURLOPT_PROXY, 'xx.xx.xx.xx:8080');

    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($mail_data));
    $result = curl_exec($ch);
    $result = curl_error($ch) ? FALSE : $result;
    curl_close($ch);

can someone help

0 likes
4 replies
Sinnbeck's avatar

You want to send mail using curl? Or was it just an example of setting up a proxy?

Laravel 8 uses swiftmailer and laravel 9 uses symfony mailer. So you might want to upgrade before trying to get it working, so you don't have to do it twice

akash-chawan's avatar

@Sinnbeck ~ i dont want to use curl. its was an example like using curl i can able to send email. but i want to use Mail::function to send email

Sinnbeck's avatar

@akash-chawan then I suggest you install a seperate project with laravel 9 and try to get it working there. Once it's working, you can upgrade you current project to 9 and copy over the code

Please or to participate in this conversation.