eXPlosion Posted March 13, 2017 Share Posted March 13, 2017 here is mail controller class <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; use App\MassMail; use App\Contact; use Illuminate\Support\Facades\Auth; use Mail; class MassMailController extends Controller { public function index() { $mails = MassMail::orderBy('date_sent', 'DESC')->get(); return view('mail.mass.index')->with('mails', $mails); } public function show($id) { $mail = MassMail::findOrFail($id); return view('mail.mass.show')->with('mail', $mail); } public function create() { $movies = Auth::user()->movies()->lists('title', 'id'); return view('mail.mass.create')->with('movies', $movies); } public function send(Requests\EmailTemplateRequest $request) { $emails = Contact::whereNotNull('email')->lists('email')->toArray(); Mail::send(['text' => 'emails.plain'], ['text' => $request->message], function ($message) use ($request, $emails) { $message->from('info@someone.com', $request->sender); $message->subject($request->subject); $message->to($emails); }); //send $mail = new MassMail($request->all()); $mail->date_sent = \Carbon\Carbon::now(); $mail->recipent_count = count($emails); \Auth::user()->massMail()->save($mail); $contacts = Contact::whereNotNull('email')->lists('id')->toArray(); foreach($contacts as $contact){ $mail->recipents()->attach($contact); } return redirect('mail/mass'); } } There is a requirement that multiple receivers won't see other receivers. Like blind copy. How to modify it? Thanks. There is also mass mail class, which looks like this: <?php namespace App; use Illuminate\Database\Eloquent\Model; class MassMail extends Model { /** * The table associated with the model. * * @var string */ protected $table = 'mass_mails'; protected $fillable = [ 'sender', 'subject', 'message', 'movie_id' ]; public $timestamps = false; public function recipents() { return $this->belongsToMany('App\Contact', 'contact_mass_mail_pivot', 'mass_mail_id', 'contact_id'); } } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/ Share on other sites More sharing options...
AzeS Posted March 13, 2017 Share Posted March 13, 2017 like a differrent sender each time or what ? Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/#findComment-1544163 Share on other sites More sharing options...
eXPlosion Posted March 13, 2017 Author Share Posted March 13, 2017 like a differrent sender each time or what ? No, receivers should not see other receivers in email (email contains many receivers). Like bcc (blind copy) in outlook Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/#findComment-1544165 Share on other sites More sharing options...
AzeS Posted March 13, 2017 Share Posted March 13, 2017 Roughly speaking; Locate the emails of the recieving people and remove them, or simplie dont do email lists like : $email_to = "jhewitt@amleo.com,some@other.com,yet@another.net"; in the first place, im no expert in this but, if i would do that, i would create a simple mail funktion and an for each loop that reads an array with all the recievers and then sends them by triggering the functionyou might use http://php.net/manual/de/class.thread.php if you have a massive ammount of emails. Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/#findComment-1544171 Share on other sites More sharing options...
eXPlosion Posted March 13, 2017 Author Share Posted March 13, 2017 (edited) I'm wondering would it work if i change $message->to($emails); to $message->bcc($emails); Edited March 13, 2017 by eXPlosion Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/#findComment-1544175 Share on other sites More sharing options...
ginerjm Posted March 13, 2017 Share Posted March 13, 2017 I don't know what actual mail command you are using or what mailing package, but usually the bcc: is setup in the header of the email being sent. Check out the simple PHP "mail()" function in the official php manual to see what the headers should have in them. 1 Quote Link to comment https://forums.phpfreaks.com/topic/303444-php-mail-sending-script/#findComment-1544184 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.