Changing Email address through phpmailer - phpmailer

Can I change <help.akunatch#gmail.com> through phpmailer?

Yes. You can set the from address using the From property (and the name via the FromName property), or using the setFrom method to do both at once:
$mail->From = 'myotheraddress#example.com';
$mail->FromName = 'Akunatech support';
or:
$mail->setFrom('myotheraddress#example.com', 'Akunatech support');
That said, I can see you're sending through gmail, which does not allow you to use arbitrary from addresses (it will revert to your account address if you try), but you can configure aliases in gmail settings.

Related

Docusign ReplyEmailAddressOverride setting, does it require a ReplyNameOverride as well?

If you use the properties in EmailSettings to change the reply email address, do you also need to assign a value to the reply name override property? If you don't, what does it use for the name?
From the legacy official REST documentation, the replyEmailNameOverride is NOT required.
While the documentation doesn't mention this, if you don't specify it, it seems that it will reuse the name of the original recipient it was sent to.
See my example below in C#:
EmailSettings settings = new EmailSettings
{
ReplyEmailAddressOverride = "otherUserThanTheSende#fakeemail.com"
};
docuSignEnvelope.EmailSettings = settings;
To go further, if you look at the DocuSign recipient email source, you can see that they assign the recipient name to the reply email as below :

Using PHPMailer when popen is disabled

Is it possible to use PHPMailer to send an email from a php script on shared hosting where popen() is disabled? I am trying to send an email using the code below but get the error message "popen has been disabled for security reasons". On checking with my host provider it has indeed been disabled and cannot be enabled on shared hosting. Does this make PHPMailer unusable for me?
$mail = new PHPMailer();
$mail->SetFrom('info#byetunes.com', 'Byetunes');
$mail->AddReplyTo($param['sender_email'], $param['sender_name']);
$mail->AddAddress($receiverEmails[0]);
$mail->isHTML(true);
$mail->isSendmail(true);
$mail->Subject = $param['subject'];
$mail->Body = $message_body;
$sendingStatus = $mail->send();
You only need popen because you're using isSendmail - why are you doing that?
If you use isMail (the default, most likely to work on shared hosting) or isSMTP, you don't need popen.

PHPMailer 5.2.x - Centrally set PHPMailer SMTPAuth credentials

We inherited an older PHP application. It is an online shop application coded in weird style. Each mail procedure has been coded into the responsive PHP file on the fly. There are lots of files which can hold code to send out mails.
Problem is, the new webserver uses a mailserver that demands SMTPAuth to accept mails for sending. The code doesn't provide any SMTPAuth credentials because the former hosting didn't use it.
The scripts are using PHPMailer.
My question is if there is any way to centrally set SMTPAuth credentials (host, username, password) which will be used by PHPMailer automatically always while sending out mails?
I do not want to touch the foreign code and alter each script so it uses SMTPAuth like:
$mail->IsSMTP = true;
$mail->Host = "blah";
$mail->Username = "xxx";
and so on.
I hope my intention is clear. Please ask if there are questions.
Don't edit the original files - otherwise when you update PHPMailer, your code will break - subclass instead, like this:
class myMailer extends PHPMailer {
public function __construct($debug = false) {
parent::__construct($debug);
$this->Username = 'username';
$this->Password = 'password';
$this->isSMTP();
$this->SMTPAuth = true;
}
}
then use it whenever you want an instance, so instead of saying
$mail = new PHPMailer;
say
$mail = new myMailer;
This approach is how you should always use libraries; it's not specific to PHPMailer.
I've solved it.
Just set the values in class.phpmailer.php of the public vars:
$Mailer // to "smtp"
$Host // to the mail host
$SMTPAuth // to true
$Username // to the mail accounts username
$Password // to the mail accounts password
That's all.

Web2py - Using a Gmail address

I am beginner with web2py. I have just created a new project.
I want to use a gmail address, let's say g#gmail.com. What do I need to modify ?
mail.settings.server = 'logging' or 'smtp.gmail.com:587' # your SMTP server
mail.settings.sender = 'g#gmail.com' # your email
mail.settings.login = 'g#gmail.com:mypassword' # your credentials or None
Is this OK ?
What is the purpose of 'logging' ?
Should be
mail.settings.server = 'smtp.gmail.com:587'
Setting mail.settings.server = 'logging' has the effects of logging to console requests for sending emails but does not send the emails. It is useful for debugging email problems.

'Microsoft.SharePoint.MailMessage' is inaccessible due to its protection level

'Microsoft.SharePoint.MailMessage' is inaccessible due to its protection level
On this code:
MailMessage mail = new MailMessage();
mail.From = "myemail#xxxxx.edu";
mail.To = "myemail#xxxx.edu";
mail.Subject = "Testing Code";
mail.BodyText = what;
mail.Priority = MailPriority.High;
Smtp.Send(mail, "smtp.xxxxx.edu");
How can remidy this? changes to web.config? Any way to circumvent in code?
This error is saying that MailMessage does not have public constructor. Most likely, it is for internal SharePoint use only.
Actually, in most cases in SharePoint you need to use SPUtility.SendEmail method to send mail with SharePoint. It is very simple:
SPUtility.SendEmail(SPContext.Current.Web, false, false, "myemail#xxxxx.edu", "Testing Code", what);
See MSDN for details on this method:
http://msdn.microsoft.com/en-us/library/ms411989.aspx
If you need to send email under ordinary user accounts, you should use SPSecurity.RunWithElevatedPrivilegies method to provide elevated privilegies.
Only disadvantage is that SPUtility does not support attachments. If you need attach some files to your letter, please use System.Net.Mail.
I know a good post from Edwin Vriethoff, which provide detailed information about sending email with attachments, with default SharePoint SMTP settings (they are configured through Central Administration):
http://edwin.vriethoff.net/2007/10/02/how-to-send-an-e-mail-with-attachment-from-sharepoint/

Resources