File attachment with PHPMailer

When you call move_uploaded_file($file_tmp,”uploads/”.$file_name); This creates a file in the uploads/ directory with the name of the file as it was named on the uploader’s computer. Then you used sample code to add the attachment to phpMailer so you’re basically attempting to attach non-existent files. These two lines: $mail->addAttachment(‘uploads/file.tar.gz’); // I took this from the … Read more

phpmailer: Reply using only “Reply To” address

I have found the answer to this, and it is annoyingly/frustratingly simple! Basically the reply to addresses needed to be added before the from address as such: $mail->addReplyTo(‘[email protected]’, ‘Reply to name’); $mail->SetFrom(‘[email protected]’, ‘Mailbox name’); Looking at the phpmailer code in more detail this is the offending line: public function SetFrom($address, $name=””,$auto=1) { $address = trim($address); … Read more

PHPMailer AddAddress()

You need to call the AddAddress function once for each E-Mail address you want to send to. There are only two arguments for this function: recipient_email_address and recipient_name. The recipient name is optional and will not be used if not present. $mailer->AddAddress(‘[email protected]’, ‘First Name’); $mailer->AddAddress(‘[email protected]’, ‘Second Name’); $mailer->AddAddress(‘[email protected]’, ‘Third Name’); You could use an array … Read more

PHPMailer – SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

PHP 5.6 introduces SSL certificate verification, so if your config is broken, it will fail with this error. You should fix your SSL, but you can revert to the old behaviour by setting the SMTPOptions property to not verify certificates: $mail->SMTPOptions = array( ‘ssl’ => array( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true … Read more

PHPMailer GoDaddy Server SMTP Connection Refused

I’m on GoDaddy on a Linux like @surfbird0713. On my 32nd attempt, the following worked for me as well: $mail2->Host = localhost; //$mail2->SMTPAuth = false; //$mail2->Username=”[email protected]”; //$mail2->Password = ‘*******’; //$mail2->SMTPSecure=”tls”; //$mail2->Port = 465; I was previously trying with the username, login, port, etc. When I commented out all those, and just went with localhost it … Read more